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!

Find and replace in Word 1

Status
Not open for further replies.

hva

Programmer
Aug 7, 2001
1
NO
Does anybody know how to find and replace text in Word 2000 from a WSH (Windows Scripting Host) - script (run from dos by the command CSCRIPT)? The WB-kode is this:
Sub test1()
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "~lf~"
.Replacement.Text = "^l"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
End Sub
The problem is the last command. Most of the code is similar or slightly different in WHS-script, but the code for execute I can't find.
 
AFAIK, VBS doesnt support named parameters, so you'll have to use their ordinal position like so

Selection.Find.Execute ,,,,,,,,,,2 Jon Hawkins
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top