I have several Word .doc files listed in a listbox and I need to search all of them to see if a certain string of text is found. I don't want any of the documents to be opened, I just want the name(s) of the documents that the text is found in, to be returned to the listbox. It should only show the founded documents in the listbox.
This far have I come with the code, as I think peet wrote. But this code are far away from complete and not okej for my purpose...
VB Code:
Option Explicit Private objWord As Word.Application Private wd As Word.Document Private Sub Command1_Click() If objWord Is Nothing Then Set objWord = CreateObject("Word.Application") Else Set objWord = GetObject(, "Word.Application") End If DoEvents Set wd = objWord.Documents.Open("c:\Test.doc")' Here i want it to get the file from the listbox. With wd.Content.Find .Text = "test" Wrap:=wdFindContinue End With objWord.ActiveDocument.Close False 'objWord.Visible = True If Not (wd Is Nothing) Then Set wd = Nothing If Not (objWord Is Nothing) Then objWord.Application.Quit If Not (objWord Is Nothing) Then Set objWord = Nothing End Sub




Reply With Quote