Link to home
Start Free TrialLog in
Avatar of dgravitt
dgravittFlag for United States of America

asked on

Search directory with Word documents for docs containing a word from Access 2007

From Access 2007, I would like to search a directory containing Word documnets and find documents that contain a specific word in the body, then write that file name to a table.
Avatar of danishani
danishani
Flag of United States of America image

Check this demo out (see attached).
SaveWordDoc.zip

Set References to Microsoft Script Runtime and Microsoft Word 12.0 Object.

Make sure you change the Pathname accordingly in the OnClick Event of the Command button.

Post back with questions.

Hope this helps,
Daniel
Newer version, with better releasing of the Objects and releasing the WINWORD.EXE instance from memory.

 SaveWordDoc-v2.zip

Hope this helps,
Daniel
Avatar of dgravitt

ASKER

Not sure I understand where to insert the directory name where the files are located.
Below new demo, including the option on Form to change Directory and option Incl. SubDir.

 SaveWordDoc-v3.zip

Hope this helps,
Daniel
This is going to work great. But, I'm getting an error 3420: Object invalid or no longer set. Seems like it is occuring after finding the first file. I only have one record written to the table.
Sometimes, before getting the error above, I get a warning this file is locked for editing. I presume it is on the next file found that meets the search criteria. The machine name is my PC that it says has the file locked.
ASKER CERTIFIED SOLUTION
Avatar of danishani
danishani
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Great solution. Thanks