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

Keyword search of MSWord Docs 1

Status
Not open for further replies.

bard9

IS-IT--Management
Jun 26, 2001
19
0
0
US
I have several MsWord Docs hyperlinked in my Access DB. I would like to set something up that would allow the user to do a keyword search of these word documents that will return doc titles that the user can then select from.

Has anyone out there done something like this? Any help would be greatly appreciated.
 
Hi there

When you say a 'keyword' search, do you actually mean the keywords property of the word document OR do you mean a word which will be provided by the user and searched for in the document ? Missy Ed - Bolton, UK
 
I am speaking of the user providing a keyword that will be searched for within the word doc. Right now, I have multiple documents hyperlinked in my Access database. I would like to give the user the opportunity to do a keyword search. This search will search the text of the documents (not just the titles) and then I am hoping return a list of document titles that the keyword appears in. From there, the user will select the appropriate choice. This will sort of be like doing a keyword search here on the net.

I am realizing this may be a lot to ask, but may be possible when creating an application with the office2K development kit.

Thanks.
 
Set a reference to msWord then use the following (or at least an adaptation of it):

Function FindWord(i_strWordToFind As String)

Dim rs As DAO.Recordset
Dim obj As Word.Application
Dim doc As Word.Document
Dim strFile As String

Set rs = CurrentDb.OpenRecordset("Select FileName from Table1")

Set obj = CreateObject("word.application")

If Not rs.EOF Then
rs.MoveFirst
Do
strFile = rs.Fields(0)

obj.Documents.Open strFile
Set doc = obj.Documents(1)

If doc.Range.Find.Execute(FindText:=i_strWordToFind) Then
MsgBox "found string in " & strFile
End If

doc.Close False
Set doc = Nothing

rs.MoveNext
Loop While Not rs.EOF
End If

obj.Quit
Set obj = Nothing

rs.Close

End Function

HTH

:)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top