D
Daem0nX
I've recorded a macro "fnr" (find n replace) that finds all styles
called H3Par and changes them over to macroH3. When I record the macro
it finds and replaces all instances of the style. However, if I reload
my document and run fnr, it doesn't find/replace any styles. The only
changes I've made to the recorded macro are If StyleExists and MsgBox -
to make sure 1) the style exists and it doesn't error out 2) to confirm
it ran the macro. I've ran the macro without the changes (default from
recording) also.
Sub fnr()
'
' fnr Macro
' Macro recorded 8/22/2006 by byron
'
If StyleExists("H3Par") Then
Selection.Find.ClearFormatting
Selection.Find.Style = ActiveDocument.Styles("H3Par")
Selection.Find.ParagraphFormat.Borders.Shadow = False
Selection.Find.Replacement.ClearFormatting
Selection.Find.Replacement.Style = ActiveDocument.Styles("macroH3")
Selection.Find.Replacement.ParagraphFormat.Borders.Shadow = False
With Selection.Find
.Text = ""
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute replace:=wdReplaceAll
MsgBox "Macro ran fine"
End If
End Sub
If you need any other details let me know.
Any help is appreciated =)
called H3Par and changes them over to macroH3. When I record the macro
it finds and replaces all instances of the style. However, if I reload
my document and run fnr, it doesn't find/replace any styles. The only
changes I've made to the recorded macro are If StyleExists and MsgBox -
to make sure 1) the style exists and it doesn't error out 2) to confirm
it ran the macro. I've ran the macro without the changes (default from
recording) also.
Sub fnr()
'
' fnr Macro
' Macro recorded 8/22/2006 by byron
'
If StyleExists("H3Par") Then
Selection.Find.ClearFormatting
Selection.Find.Style = ActiveDocument.Styles("H3Par")
Selection.Find.ParagraphFormat.Borders.Shadow = False
Selection.Find.Replacement.ClearFormatting
Selection.Find.Replacement.Style = ActiveDocument.Styles("macroH3")
Selection.Find.Replacement.ParagraphFormat.Borders.Shadow = False
With Selection.Find
.Text = ""
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute replace:=wdReplaceAll
MsgBox "Macro ran fine"
End If
End Sub
If you need any other details let me know.
Any help is appreciated =)