Find & Replace

R

Rick English

How can I get the following subroutine to search and replace in the headers
and footers as well. The document has three sections with different headers
Thanks

Sub find_replace_text(oldtext As String, newtext As String)
Dim newtext1 As String
newtext1 = Replace(newtext, Chr$(10), "")
newtext1 = Replace(newtext1, Chr$(13), "^p")
' find_replace Macro
Set myrange = ActiveDocument.Content
'newtext1 = Check_Text(newtext)

With myrange.Find
.ClearFormatting
.Text = oldtext
With .Replacement
.Text = newtext1
End With
.Execute Replace:=wdReplaceAll

End With

End Sub
 
R

Rick English

Wow

That's amazing. It works but it will be a long time before I fully
understand it.

The work object is pretty amazing


Thanks

Rick
 

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