Click here to Skip to main content
14,638,971 members
Rate this:
Please Sign up or sign in to vote.
See more:
Hi all,

I'm trying to use the following script to search all types of documents not just txt. Specifically word and excel. Is this an easy fix?

dim filesys
set filesys=CreateObject("Scripting.FileSystemObject")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Dim objShell
set objShell = CreateObject("WScript.Shell")

x=msgbox("Word Search Started",0,"Word Check")

strSearchFor = "word"
Set oFSO = CreateObject("Scripting.FileSystemObject")
objStartFolder = "C:\Test1\"
 
Set objFolder = objFSO.GetFolder(objStartFolder)
 
Set colFiles = objFolder.Files
For Each objFile in colFiles
    strFile = "C:\Test1\" & objFile.Name
    set objFile = objFSO.getFile(strFile)
    if objFile.size > 0 then
        If InStr(oFSO.OpenTextFile(strFile).ReadAll, strSearchFor) > 0 Then
	    x=msgbox("Word Found!",16,"Word Check")
        Else
	    x=msgbox("No Word Found",0,"Word Check")
            WScript.Sleep (100)
        END If
    END If
Next
Posted

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

Try using my article instead : hOOt - full text search engine[^]
   
Comments
Member 10761166 20-Apr-14 1:50am
   
Thanks Mehdi, but this is part of a larger script that I need to be more flexible.
Mehdi Gholam 20-Apr-14 2:04am
   
Well you can't search binary files like word and excel with a script like that, you need IFilter parsers to extract the full text etc.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100