M
mmikedm1000
I have two questions concerning using a macro to find styles and replace them
with other styes.
First I am using this code to find and replace a styles
'
' Finds Style "Heading 4" and Replaces it with Style "Heading 3"
'
Selection.HomeKey Unit:=wdStory
Selection.Find.ClearFormatting
On Error Resume Next
Selection.Find.Style = ActiveDocument.Styles("Heading 4")
Selection.Find.Replacement.ClearFormatting
Selection.Find.Replacement.Style = ActiveDocument.Styles("Heading 3")
With Selection.Find
.Text = ""
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = True
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
I have many styles that are currently in a word document that I want the
macro to find and replace with the style body for instance. Is there a
better way to code this so that maybe five or more different styles can be
replaced with the style body.
My second question is if there is a way to code a find replace to replace an
inline style (maybe wrong terminology) with a defined style.
For example, replacing "body + bold" with "emphasis"
Thanks for any help,
with other styes.
First I am using this code to find and replace a styles
'
' Finds Style "Heading 4" and Replaces it with Style "Heading 3"
'
Selection.HomeKey Unit:=wdStory
Selection.Find.ClearFormatting
On Error Resume Next
Selection.Find.Style = ActiveDocument.Styles("Heading 4")
Selection.Find.Replacement.ClearFormatting
Selection.Find.Replacement.Style = ActiveDocument.Styles("Heading 3")
With Selection.Find
.Text = ""
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = True
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
I have many styles that are currently in a word document that I want the
macro to find and replace with the style body for instance. Is there a
better way to code this so that maybe five or more different styles can be
replaced with the style body.
My second question is if there is a way to code a find replace to replace an
inline style (maybe wrong terminology) with a defined style.
For example, replacing "body + bold" with "emphasis"
Thanks for any help,