Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

problem with vbscript & ms-word search 1

Status
Not open for further replies.

jfdabiri

MIS
Feb 27, 2007
282
US
hi
i have this script that worked with ms-word 2000 with win-xp. i imported this script to xp with ms-word 2007. the script is not working with the following error msg:
"this command is not available on this platform"
here's the code:
Code:
Set objWord = CreateObject("Word.Application")
Set objDoc = objWord.Documents.Add()

search_string = "field"
objWord.FileSearch.NewSearch
objWord.FileSearch.FileName = typ
objWord.FileSearch.LookIn = dir
objWord.FileSearch.SearchSubfolders = True
objWord.FileSearch.MatchTextExactly = True
objWord.FileSearch.TextOrProperty = search_string

objWord.FileSearch.Execute

For Each objFile in objWord.FileSearch.FoundFiles 

    if right(objFile, 3) = "vbs" then 
       msg = msg & objFile & vbcrlf         
    end if    
Next
any ideas what is missing?
thanks.
 
thanks so much, phv.
i'm going to look at this solution
cheers.
 
phv,
i tried that. it can't figure out the provider:
Code:
Set objConnection = CreateObject("ADODB.Connection")
Set objRecordSet = CreateObject("ADODB.Recordset")

objConnection.Open "Provider=Search.CollatorDSO;Extended Properties='Application=Windows';"

objRecordSet.Open "SELECT System.FileName FROM SYSTEMINDEX WHERE System.FileExtension = '.vbs'", _
    objConnection

objRecordSet.MoveFirst

Do Until objRecordset.EOF
    msgbox objRecordset.Fields.Item("System.FileName")
    objRecordset.MoveNext
Loop
it give error:
provider can not be found. may not be properly installed.


 
Do you have Windows Desktop Search 3.0 installed ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
phv,
thanks. i'm not sure what that is. is that the same thing that you launch from start-button/search-for-files?
or is it a stand-alone app that i have to get?
thanks.
 
phv,
i got the desktop search 3.0 installed. it just searches the desktop, as the name says. i got it to work. and it shows files of any type i specify.
the word.search would let me specify a particular folder, and search for a string in each file. is that possible.
thanks.
 
Perhaps this ?
objRecordSet.Open "SELECT System.FileName FROM SYSTEMINDEX WHERE System.FileExtension = '.vbs'" _
& " AND CONTAINS('SearchedWord')", objConnection

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
phv,
thanks for your reply. so far i have got the desktop thing to work. it only searches the desktop though. i will use this posting of yours to try to tweak the content. how would i get around specifying a specific directory?
thanks again.
 
either:
" AND System.ItemFolderPathDisplay = 'C:\Path\to\dir'"
or (if you want to search subfolders too):
" AND System.ItemPathDisplay LIKE 'C:\Path\to\dir\%'"

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
phv,
thanks. the "contain" part works, but it's not finding anything when a directory is specified. it returns eof or bof error.
even though directory has the files that do contain the string.
thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top