views:

230

answers:

1

Hi, I have an word document which I want to convert to text (.txt) file programmatically. I am using C# for this. I am able to read paragraphs and tables from word document and convert them to text. There are some textboxes in the word document and those textboxes contain text that I want to read and put them in text file. My problem is I do not know in which collection those textboxes are stored. For example, all tables are stored in tables collection, paragraphs in paragraphs collection. Can anyone please tell me how to read from these text boxes? Please let me know if you need any additional information.

I forgot to mention, I am using MS Office 2003.

Many Thanks,

+2  A: 

There are text boxes and text frames. I'm pretty sure any text inside text boxes will be part of the Doc.Content range.

To find all the text frames in a document, I use this VBA code:

Dim Doc As Document
Dim Range As Range

' Load document

Set Range = Doc.StoryRanges(wdTextFrameStory)
Do Until Range Is Nothing
    ' Do something with Range.Text
    Set Range = Range.NextStoryRange
Loop
Foole