macro runs but does not work as expected

U

Ulrike

Hi, I created a macro by recording search and replace actions (replacing text
as well as styles). The actions worked fine when recording the macro. The
macro runs without error - but also without any effect.

Thanks in advance for your support and best regards! Ulrike

==

Here is one of the actions of the macro:

--
Selection.Find.ClearFormatting
Selection.Find.Style = ActiveDocument.Styles("Heading 1")
Selection.Find.ParagraphFormat.Borders.Shadow = False
Selection.Find.Replacement.ClearFormatting
Selection.Find.Replacement.Style = ActiveDocument.Styles("Ãœberschrift 1")
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

--

And here is the whole macro (but as far as I can see, in principle the
find-replace action is just repeated with other parameters):

Sub Signum_Manuskript_Formatvorlagen()
'
' Signum_Manuskript_Formatvorlagen Makro
' Makro aufgezeichnet am 10.12.2006 von Ulrike Schäfer
'
Selection.Find.ClearFormatting
Selection.Find.Style = ActiveDocument.Styles("Heading 1")
Selection.Find.ParagraphFormat.Borders.Shadow = False
Selection.Find.Replacement.ClearFormatting
Selection.Find.Replacement.Style = ActiveDocument.Styles("Ãœberschrift 1")
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
Selection.Find.ClearFormatting
Selection.Find.Style = ActiveDocument.Styles("Heading 1")
Selection.Find.ParagraphFormat.Borders.Shadow = False
Selection.Find.Replacement.ClearFormatting
Selection.Find.Replacement.Style = ActiveDocument.Styles("Ãœberschrift 1")
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
Selection.Find.ClearFormatting
Selection.Find.Style = ActiveDocument.Styles("Heading 1")
Selection.Find.ParagraphFormat.Borders.Shadow = False
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "^p"
.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
Selection.Find.ClearFormatting
Selection.Find.Style = ActiveDocument.Styles("Heading 2")
Selection.Find.ParagraphFormat.Borders.Shadow = False
Selection.Find.Replacement.ClearFormatting
Selection.Find.Replacement.Style = ActiveDocument.Styles("Ãœberschrift 2")
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
Selection.Find.ClearFormatting
Selection.Find.Style = ActiveDocument.Styles("Heading 2")
Selection.Find.ParagraphFormat.Borders.Shadow = False
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "^p"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
End Sub
 
T

Tony Jollans

The recording of macros for Find and Replace is not perfect - and the border
setting in this case is a bit suspicious. What exactly did you replace and
want to replace with what?

--
Enjoy,
Tony

Ulrike said:
Hi, I created a macro by recording search and replace actions (replacing
text
as well as styles). The actions worked fine when recording the macro. The
macro runs without error - but also without any effect.

Thanks in advance for your support and best regards! Ulrike

==

Here is one of the actions of the macro:

--
Selection.Find.ClearFormatting
Selection.Find.Style = ActiveDocument.Styles("Heading 1")
Selection.Find.ParagraphFormat.Borders.Shadow = False
Selection.Find.Replacement.ClearFormatting
Selection.Find.Replacement.Style = ActiveDocument.Styles("Ãœberschrift
1")
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

--

And here is the whole macro (but as far as I can see, in principle the
find-replace action is just repeated with other parameters):

Sub Signum_Manuskript_Formatvorlagen()
'
' Signum_Manuskript_Formatvorlagen Makro
' Makro aufgezeichnet am 10.12.2006 von Ulrike Schäfer
'
Selection.Find.ClearFormatting
Selection.Find.Style = ActiveDocument.Styles("Heading 1")
Selection.Find.ParagraphFormat.Borders.Shadow = False
Selection.Find.Replacement.ClearFormatting
Selection.Find.Replacement.Style = ActiveDocument.Styles("Ãœberschrift
1")
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
Selection.Find.ClearFormatting
Selection.Find.Style = ActiveDocument.Styles("Heading 1")
Selection.Find.ParagraphFormat.Borders.Shadow = False
Selection.Find.Replacement.ClearFormatting
Selection.Find.Replacement.Style = ActiveDocument.Styles("Ãœberschrift
1")
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
Selection.Find.ClearFormatting
Selection.Find.Style = ActiveDocument.Styles("Heading 1")
Selection.Find.ParagraphFormat.Borders.Shadow = False
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "^p"
.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
Selection.Find.ClearFormatting
Selection.Find.Style = ActiveDocument.Styles("Heading 2")
Selection.Find.ParagraphFormat.Borders.Shadow = False
Selection.Find.Replacement.ClearFormatting
Selection.Find.Replacement.Style = ActiveDocument.Styles("Ãœberschrift
2")
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
Selection.Find.ClearFormatting
Selection.Find.Style = ActiveDocument.Styles("Heading 2")
Selection.Find.ParagraphFormat.Borders.Shadow = False
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "^p"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
End Sub
 
T

Tony Jollans

Glad you're sorted but I would be interested to know what you recorded in
order to get the border settings as they are - or if you can recreate the
situation.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top