Click here to Skip to main content
15,888,113 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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?

VB
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

Try using my article instead : hOOt - full text search engine[^]
 
Share this answer
 
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, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900