AndrewPerl
02-03-2006, 01:43 PM
I am having issues with the Find and Replace function in Word. The following code only replaces the tag [CLIENT NAME] in the body of the document. It ignores all tags that appear in text boxes and in headers or footers.
If I manually invoke the Find and Replace everything works fine. The following code is one of many iterations I have tried. Is it something to do with the range? I have tried range with start and end set to 0. I have also tried ActiveDocument.Content... all with no success. Please help.
Public Sub Customize_Doc()
Dim CL_Name, Client_Replace, Quarter, Doc_Year
CL_Name = "[CLIENT NAME]"
Quarter = "[QUARTER]"
Doc_Year = "[YEAR]"
Client_Replace = InputBox("Enter the name of the client.", "Client Name")
Set myrange = ActiveDocument.Content
myrange.Find.Execute Findtext:=CL_Name, ReplaceWith:=Client_Replace, Replace:=wdReplaceAll
End Sub
Thanks,
Andrew Perl in Kansas City
If I manually invoke the Find and Replace everything works fine. The following code is one of many iterations I have tried. Is it something to do with the range? I have tried range with start and end set to 0. I have also tried ActiveDocument.Content... all with no success. Please help.
Public Sub Customize_Doc()
Dim CL_Name, Client_Replace, Quarter, Doc_Year
CL_Name = "[CLIENT NAME]"
Quarter = "[QUARTER]"
Doc_Year = "[YEAR]"
Client_Replace = InputBox("Enter the name of the client.", "Client Name")
Set myrange = ActiveDocument.Content
myrange.Find.Execute Findtext:=CL_Name, ReplaceWith:=Client_Replace, Replace:=wdReplaceAll
End Sub
Thanks,
Andrew Perl in Kansas City