Simple search and replace

C

CBenac

I would like to see an vba example for a simple search and replace in a word
document. The search string ( "##co_name" ) may exist in more than one page
in the document body, but it won't be found in the header or the footer.

TIA
 
H

Helmut Weber

Hi CBenac,

try that:

Sub Test444a()
Dim rDcm As Range
Set rDcm = ActiveDocument.Range
With rDcm.Find
.Text = "##co_name"
.Replacement.Text = "MyFirm"
.Execute Replace:=wdReplaceAll
End With
End Sub
--

Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Vista Small Business, Office XP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top