1

Is there a way (in VB.net/VBA) to search for a string in a .doc file without physically opening it?

The question may sound silly but I have code that searches 100's of documents at a time while opening them all up one-by-one (using For Each, FileSystemObjectand oWord.Document.Open(Filename.doc) and it takes ages.

I noticed that when you search for a document using the search box in Windows Explorer, the results are returned having found your search term in the TITLE of the document as well as the the CONTENTS of the document within the search window. The results where the search term was found INSIDE the document appears as a sort of text preview of all the text inside that document.I could be wrong but I read somewhere that all word documents contain some sort of xml file embedded within that contains (among other things) the text from the document itself.

So my question is, if Windows Explorer can do it without having to open a word process, can the same be done in code (VBA or VB.NET)to find a particular word inside a document?

Hope that makes sense,

Thanks.

The Benetrator
  • 367
  • 7
  • 18

0 Answers0