Macro not working properly


G

Guest

I have recorded a macro to find two consecutive paragraph marks and replace
them with one paragraph mark, formatted with 12pt spacing after. THis works,
but also puts a border round the text. I do not really understand Visual
Basic, and therefore cannot edit the macro. Could someone please help? Below
is the macro:

Sub RemoveTwooParaMarks()
'
' RemoveTwooParaMarks Macro
' Remove 2 para marks replace with one para mark format 12 pt spacing after
'
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find.Replacement.ParagraphFormat
.SpaceBeforeAuto = False
.SpaceAfter = 12
.SpaceAfterAuto = False
.LineUnitAfter = 0
End With
Selection.Find.Replacement.ParagraphFormat.Borders.Shadow = False
With Selection.Find
.Text = "^p^p"
.Replacement.Text = "^p"
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
End Sub
 
Ad

Advertisements

C

Cindy M -WordMVP-

Hi Misha,

Try deleting the one line in your macro that mentions "Borders". I think that's
turning the borders on. No idea why the macro recorder put that in, but you
don't need it.
I have recorded a macro to find two consecutive paragraph marks and replace
them with one paragraph mark, formatted with 12pt spacing after. THis works,
but also puts a border round the text. I do not really understand Visual
Basic, and therefore cannot edit the macro. Could someone please help? Below
is the macro:

Sub RemoveTwooParaMarks()
'
' RemoveTwooParaMarks Macro
' Remove 2 para marks replace with one para mark format 12 pt spacing after
'
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find.Replacement.ParagraphFormat
.SpaceBeforeAuto = False
.SpaceAfter = 12
.SpaceAfterAuto = False
.LineUnitAfter = 0
End With
Selection.Find.Replacement.ParagraphFormat.Borders.Shadow = False
With Selection.Find
.Text = "^p^p"
.Replacement.Text = "^p"
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
End Sub

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or reply
in the newsgroup and not by e-mail :)
 
Ad

Advertisements

C

Cindy M -WordMVP-

Hi Misha,

Try deleting the one line in your macro that mentions "Borders". I think that's
turning the borders on. No idea why the macro recorder put that in, but you
don't need it.
I have recorded a macro to find two consecutive paragraph marks and replace
them with one paragraph mark, formatted with 12pt spacing after. THis works,
but also puts a border round the text. I do not really understand Visual
Basic, and therefore cannot edit the macro. Could someone please help? Below
is the macro:

Sub RemoveTwooParaMarks()
'
' RemoveTwooParaMarks Macro
' Remove 2 para marks replace with one para mark format 12 pt spacing after
'
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find.Replacement.ParagraphFormat
.SpaceBeforeAuto = False
.SpaceAfter = 12
.SpaceAfterAuto = False
.LineUnitAfter = 0
End With
Selection.Find.Replacement.ParagraphFormat.Borders.Shadow = False
With Selection.Find
.Text = "^p^p"
.Replacement.Text = "^p"
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
End Sub

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or reply
in the newsgroup and not by e-mail :)
 

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