WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

OLE with Word

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

WORD Find and replace

Keywords:   WORD Find and replace

Here is VB code that will do a find and replace -- someone might want to convert it to Winbatch. Probably the only problem you will have is with the Execute method as it uses positional parameters.

For reference, see the list of OLE constants in the DB.



Option Explicit

Sub ExecuteReplace()
' This procedure demonstrates using the Execute 
' method to replace text.

' Open the file.
Documents.Open FileName:="c:\odept1dc.doc"
Documents("odept1dc.doc").Activate

' Loop until no more items are found.
Do
Selection.Find.ClearFormatting
With Selection.Find
.Text = "display"
.Execute ReplaceWith:="show", _
Replace:=wdReplaceAll, Forward:=True
End With
' Exit the loop when the search is unsuccessful.
If Selection.Find.Execute = False Then Exit Do
Loop

End Sub


Article ID:   W15665
File Created: 2003:05:13:11:29:24
Last Updated: 2003:05:13:11:29:24