Group:  Microsoft Word ยป microsoft.public.word.vba.beginners
Thread: Simple search and replace

Simple search and replace
CBenac 12/27/2008 1:16:01 AM
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

--
CBenac
Re: Simple search and replace
Helmut Weber <red.sys[ at ]t-online.de> 12/27/2008 1:28:41 AM
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

Home | Search | Terms | Imprint
Newsgroups Reader