View Single Post
 
Old 06-06-2019, 11:27 AM
gmaxey gmaxey is offline Windows 10 Office 2016
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,429
gmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the rough
Default

Code:
Sub replace3()
Dim oRng As Range
Dim hf As Word.HeaderFooter
For Each hf In ActiveDocument.Sections(1).Headers
  Set oRng = hf.Range
  With oRng.Find
    .ClearFormatting
    .Replacement.ClearFormatting
    .Text = "Springtown"
    .Replacement.Text = ""
    .Forward = True
    .Wrap = wdFindStop
    .Format = False
    .MatchWildcards = True
    While .Execute
      hf.Range.Fields.Add oRng, wdFieldEmpty, "MERGEFIELD Address_line1", False
      oRng.Collapse wdCollapseEnd
    Wend
  End With
Next
End Sub
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote