A
andreas
Dear Experrts,
for some specific reason, I would like to be able to replace text in
ALL HEADER stories running just one macro.
If I set the range, I am only able to set the PRIMARYHEADER OR
EVENPAGES HEADER OR THE FIRSTPAGE HEADER STORY, but not all at the
same time.
How do I have to alter below macro to include all HEADER STORIES in
all sections (The documents I am working on have several sections)?
Help is appreciated. Thank you very much in advance for your valuable
help.
Sub ReplaceTextHeaderStories()
Dim rng As Range
Dim AskText As String
Dim AskReplacementText As String
AskText = InputBox("Please enter the text that needs to be replaced?",
"Text to be replaced")
AskReplacementText = InputBox("Please enter the replacement text",
"Replacement Text")
Set rng = ActiveDocument.StoryRanges(wdEvenPagesHeaderStory)
With rng.Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = AskText
.Replacement.Text = AskReplacementText
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchWildcards = False
.Execute Replace:=wdReplaceAll
End With
End Sub
for some specific reason, I would like to be able to replace text in
ALL HEADER stories running just one macro.
If I set the range, I am only able to set the PRIMARYHEADER OR
EVENPAGES HEADER OR THE FIRSTPAGE HEADER STORY, but not all at the
same time.
How do I have to alter below macro to include all HEADER STORIES in
all sections (The documents I am working on have several sections)?
Help is appreciated. Thank you very much in advance for your valuable
help.
Sub ReplaceTextHeaderStories()
Dim rng As Range
Dim AskText As String
Dim AskReplacementText As String
AskText = InputBox("Please enter the text that needs to be replaced?",
"Text to be replaced")
AskReplacementText = InputBox("Please enter the replacement text",
"Replacement Text")
Set rng = ActiveDocument.StoryRanges(wdEvenPagesHeaderStory)
With rng.Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = AskText
.Replacement.Text = AskReplacementText
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchWildcards = False
.Execute Replace:=wdReplaceAll
End With
End Sub