Sub Test()
ForceCocaToPepsi ActiveDocument
ForcePepsiToCoca ActiveDocument
End Sub
Public Sub ForceCocaToPepsi(ByRef oDoc As Word.Document)
Dim lngSection As Long, lngIndex As Long
Dim oRng As Word.Range
For lngSection = 1 To oDoc.Sections.Count
For lngIndex = 1 To 3
Set oRng = oDoc.Sections(lngSection).Headers(lngIndex).Range
oRng.End = oRng.End - 1
If InStr(1, oRng.Text, "sanofi pasteur") Then
oDoc.Sections(lngSection).Headers(lngIndex).Range.Text = Replace(oRng.Text, "Coca", "Pepsi")
End If
Next lngIndex
Next lngSection
lbl_Exit:
Exit Sub
End Sub
'or
Public Sub ForcePepsiToCoca(ByRef oDoc As Word.Document)
Dim lngSection As Long, lngIndex As Long
Dim oRng As Word.Range
For lngSection = 1 To oDoc.Sections.Count
For lngIndex = 1 To 3
Set oRng = oDoc.Sections(lngSection).Headers(lngIndex).Range
With oRng.Find
.Text = "Pepsi"
.Replacement.Text = "Coca"
.Execute Replace:=wdReplaceAll
End With
Next lngIndex
Next lngSection
lbl_Exit:
Exit Sub
End Sub