Filesearch...

  • Thread starter Juan Carlos Biancotti
  • Start date
J

Juan Carlos Biancotti

How can'I search the files what are including a string?

(+ Filesearch)

Tank
Juan Carlos Biancotti
(e-mail address removed)
 
S

Steve Lang

Hola Juan Carlos,

If you are looking to search a folder of files to see if any have a specific
string, use something like this:

Sub foo()
Dim i As Long
Dim oRange As Range

With Application.FileSearch
'Search in foldername
.LookIn = "C:\Test"
.SearchSubFolders = False
.FileName = "*.doc"
.Execute
For i = 1 To .FoundFiles.Count
Documents.Open FileName:=(.FoundFiles(i))
With oRange.Find
.ClearFormatting
.Forward = True
.MatchWildcards = False
.Text = "Hello World"
.MatchCase = False
.Execute
End With
If oRange.Find.Found Then MsgBox "Text Found."
'Close document
ActiveDocument.Close savechanges:=wdDoNotSaveChanges
Next i
End With

'clean up and exit
Set oRange = Nothing

End Sub

HTH and have a great day!

Steve Lang
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top