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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Searching Word Documents

Status
Not open for further replies.

scottydd

IS-IT--Management
Sep 19, 2002
31
US
I would like to be able to search particular Microsoft Word Documents for containing text, can i do this with VBScript or should i use something different? I know you can do containing text searches thru Windows Explorer, but the problem is that i only need to search about 12 documents out of 5k documents that are in the directory. Any help would be appreciated.

Thanks,
Scott
 
You may or may not get away with opening a Word document as Text (FSO.OpenTextFile) and either reading line-by-line or ReadAll. Obviously the Word format contains a fair amount of non-Ascii data, maybe the your string will be findable in that, maybe not. One problem is some characters (eg chr(0)) may be treated as an end-of-file.

The proper way to do it would be to open a Word COM object, probably (I dont know the details):
set WordObj = CreateObject( "Word.Application")
I guess theres an OpenDocument method or you .add to the Documents collection - open each document. Then either convert it all to Text so you can use Instr, or more sophisticated again, use Words build-in Find/Select methods.

Personally, I would consider automating a dump of the Word documents to text files, so that search can be very simple.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top