Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Search/Read a MS-Word Document 1

Status
Not open for further replies.

DougAlthaus

Programmer
May 29, 2001
9
US
Does anyone know of an easy way to read/search a word document? I have to read about 9000 documents once a month. If I use the ole component to open the document after so many I receive I have committed a series error in word.

It there a was to use the microsoft find?

PLEASE HELP!
 
Hello

If you specifically want to do this programmatically to find specific items in the docs then the following will help;

Code:
'this bit of code ensure that only one instance of word is loaded by this procedure
Set WordApp = GetObject(, "Word.Application.8")
If Err.Number <> 0 Then
    Err.Clear
    Set WordApp = CreateObject(&quot;Word.Application.8&quot;)
end if
WordApp.activewindow.Close (0)

'this bit opens your document - targetdoc may be an iterative get directory file i.e. open each document in a directory
WordApp.Documents.Add (TargetDoc)

If WordApp.activedocument.content.Find.Execute (findText:=&quot;SearchText&quot;) = True then
'Do your thing as the document has what you're after
end if
This should make Word a little happier.

There is a 'Find All Microsoft Documents' dialog but I've never used it (maybe that will do what you wish)


Hope this helps
 
when i run it i get the error:
ActiveX component can't create object or return reference to this object (Error 429) when it trys to

Set WordApp = GetObject(, &quot;Word.Application.8&quot;)

any ideas???
 
A couple of things.

You must have error trapping set to 'Break on unhandled errors' (this because it's trying to use an open instance before creating a new instance and the only way to trap it is to trap the error)

Also if you are using Word 2000 you need 'Word.Application.9'
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top