Scan the file contents for a word and list them if it exists

Sanmrxl

New Member
Joined
Aug 1, 2007
Messages
36
I require to list all files which have the text "Request" in its contents
(for eg . if a doc file "EXAMPLE.doc" contains the word "Request" in its contents, it should get listed).

All this without opening the files in the directory or subdirectory.

Please note -
1) the file type could be anything from DOC, XL, PPT ( mostly MSoffice files)

2) the requirement is not to scan the file name -- it is to scan the contents of the file for the given word ( "Request" as stated above, for example)

Thanks
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
OK, change path as appropriate, although if you had in mind your whole hard drive I have no idea how long this is going to take, but it will probably be a very long time.

Code:
Sub test()
Dim i As Long
With Application.FileSearch
    .NewSearch
    .LookIn = "C:\test"
    .SearchSubFolders = True
    .TextOrProperty = "Request"
    If .Execute() > 0 Then
        For i = 1 To .FoundFiles.Count
            Range("A" & Rows.Count).End(xlUp).Offset(1) = .FoundFiles(i)
        Next i
    End If
End With
End Sub
 
Upvote 0
I assume you know this is a standard feature that, depending on the use you're putting the results to, doesn't need excel's intervention...
 
Upvote 0

Forum statistics

Threads
1,214,661
Messages
6,120,796
Members
448,994
Latest member
rohitsomani

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top