A
adsoftware
The find/replace feature of VBA doesn't seem to work
within headers & footers. HELP.
I'm attaching my generic code below for your review.
Sub ReplaceHeadersFooters(sFind As String, sReplace As
String)
Dim MySelection As Variant
Dim vntStories As Variant
Dim x As Long
With ActiveDocument
For x = 0 To .StoryRanges.Count - 1
Set MySelection = ActiveDocument.StoryRanges(1)
With MySelection.Find
.Text = sFind
.Replacement.Text = sReplace
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = True
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
.Execute Replace:=wdReplaceAll
End With
Next x
End With
End Sub
within headers & footers. HELP.
I'm attaching my generic code below for your review.
Sub ReplaceHeadersFooters(sFind As String, sReplace As
String)
Dim MySelection As Variant
Dim vntStories As Variant
Dim x As Long
With ActiveDocument
For x = 0 To .StoryRanges.Count - 1
Set MySelection = ActiveDocument.StoryRanges(1)
With MySelection.Find
.Text = sFind
.Replacement.Text = sReplace
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = True
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
.Execute Replace:=wdReplaceAll
End With
Next x
End With
End Sub