开发者

How to read text that is present in text box of MS word document?

开发者 https://www.devze.com 2022-12-20 01:12 出处:网络
I have an word document which I want to convert to text (.txt) file programmatically. I am using C# for this.

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? Pl开发者_运维技巧ease let me know if you need any additional information.


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
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号