Extract All Text In Word Doc

B

Binder

In a VB app, I want to extract all of the text from a Word doc, excluding
any graphic content.
I want to load the text into a var so I can insert it into a database.

Does the word object have such support?

Thanks
 
J

Jonathan West

Binder said:
In a VB app, I want to extract all of the text from a Word doc, excluding
any graphic content.
I want to load the text into a var so I can insert it into a database.

Does the word object have such support?

Thanks

Hi Binder

Try this

Dim strContent As String
strContent = ActiveDocument.Range.Text

this gets you all the text, unformatted, in the main body of the document,
i.e. excluding headers, footers and textboxes.
 
A

Alessandro Cavalieri

I need to substitute a text that is in a text control located in the header,
but ActiveDocument.Range(0,0).Find.Execute(...) or
ActiveDocument.Content.Find.Execute(...) didn't find the text I need to
replace.
If the text is in the document body everything works well.

Do you have some suggestion or, even better, an example?

Thanks,
Alessandro
 
J

Jonathan West

Alessandro Cavalieri said:
I need to substitute a text that is in a text control located in the header,
but ActiveDocument.Range(0,0).Find.Execute(...) or
ActiveDocument.Content.Find.Execute(...) didn't find the text I need to
replace.
If the text is in the document body everything works well.

Do you have some suggestion or, even better, an example?

What kind of text control, and which header (i.e. which section, and is it
the first page header, the normal header the odd pages header or the even
pages header)?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top