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!

Search text in Word doc from Acess

Status
Not open for further replies.

PGM2

Technical User
Mar 10, 2004
30
US
Hello all its been a while since I have been here but this site has always been useful. Thanks to all that have helped me in the past. Well I have a new question and I'm hoping I can get some thoughts.
I have probably 40 msword documents that I have indexed within access and I would like to know how I can search for a string inside all of those documents. Once found I would like it to display which documents it found a match in. Is there a way to do this or is there an easier way I should consider to accomplish this? Bottom line is I would like a search mechanism to look into the docs and list the ones it finds a match to.
 
I'm sure there is a better way but I put this in a click event and though the return number is higher then I expected, it does return >0 for the text that is in the string.
Code:
Private Sub Command5_Click()
Dim sWordSearch As String
Dim returnDate As Date
Dim icount As Integer
Dim sSearchThis As String

sWordSearch = "There will be no training on Wednesday so spend the day going over the rest of chapter 6 in your inspection manual. You will also need to start reading on fire behavior and ventilation for next weeks drill."

sSearchThis = "sThe dog died"

icount = InStr(1, sWordSearch, sSearchThis)
MsgBox icount

sSearchThis = "day going over"

icount = InStr(1, sWordSearch, sSearchThis)
MsgBox icount


End Sub
 
Word has a search function, so you could create an instance of Word and then cycle through the documents, opening each one in Word and running the search function. If a match is found you know the document name and the function should tell you where the string was found in the document.


Hope this helps.

[vampire][bat]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top