View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
jack jack is offline
external usenet poster
 
Posts: 186
Default using application.filesearch for searching text in PDF

I would use application.filesearch in a excel macro
for searching the body text of PDF files, it works with office files but not
with pdf.

Any possible solution or alternatives to filesearch?
Below my code

Private Sub CommandButton1_Click()
Dim files As Variant
Dim name As Variant
Set fs = CreateObject("Scripting.FileSystemObject")
Cells.ClearContents
With Application.FileSearch
.NewSearch
.LookIn = (UserForm1.TextBox1)
.SearchSubFolders = True
.TextOrProperty = (UserForm1.TextBox2)
.FileType = msoFileTypeAllFiles
If .Execute() 0 Then
Cells(1, 1) = "There were " & .FoundFiles.Count & _
" file(s) found."
For i = 1 To .FoundFiles.Count
files = .FoundFiles(i)
name = fs.getfilename(files)
Cells(i + 2, 1).Hyperlinks.Add Anchor:=Cells(i + 2, 1),
Address:=files, TextToDisplay:=name
Next i
Else
Cells(1, 1) = "There were no files found."
End If
End With

Thank you in advance