Advertisement
Guest User

Untitled

a guest
Sep 12th, 2017
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Sub FindText()
  2. Dim i As Integer
  3.  
  4. 'Search criteria
  5. With Application.FileSearch
  6.     .LookIn = "c:\my documents\logs" 'path to look in
  7.    .FileType = msoFileTypeAllFiles
  8.     .SearchSubFolders = False
  9.     .TextOrProperty = "*Find*" 'Word to find in this line
  10.    .Execute 'start search
  11.  
  12. 'This loop will bring up a message box with the name of
  13. 'each file that meets the search criteria
  14.    For i = 1 To .FoundFiles.Count
  15.         MsgBox .FoundFiles(i)
  16.     Next i
  17.  
  18. End With
  19.  
  20. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement