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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Testing the condition of a Find in Word using VBscript

Status
Not open for further replies.

kadlec

Programmer
Nov 5, 2001
2
AU
Help,

I have a situation where I need to search for specific string and if it exists then do some formating.

What I did was to record a macro in Word and then translate it back to VBS. This seemed to work on one of my machines under Windows ME and Word 2000. However I have tried using under Word 97 and get the error "Object doesn't support this property or method" at the line "objWord.Selection.Find.Excecute".

What am I doing wrong?.

Can any body suggest a way of doing this?

I am only new to VBscript and how to intergrate it into applications. Most of my experiance has been writing system in character based languages. Any help you can give will be appreciated.

Thanks

EXTRACT OF CODE

Set objWord = WScript.CreateObject("Word.Application")

objWord.ActiveWindow.View.Type = 1 'wdNormalView
objWord.Selection.Find.ClearFormatting
objWord.Selection.Find.Text = &quot;<<TSTATUS>>&quot;
objWord.Selection.Find.Replacement.Text = &quot;&quot;
objWord.Selection.Find.Forward = True
objWord.Selection.Find.Wrap = 1 'wdFindContinue
objWord.Selection.Find.Format = False
objWord.Selection.Find.MatchCase = False
objWord.Selection.Find.MatchWholeWord = False
objWord.Selection.Find.MatchWildcards = False
objWord.Selection.Find.MatchSoundsLike = False
objWord.Selection.Find.MatchAllWordForms = False
objWord.Selection.Find.Excecute
if objWord.Selection.Find.Found Then
do something!!!!
end if
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top