Macro

G

Guest

I have recorded a macro in Word 2003 which removes two consecutive paragraph
marks and replaces them with one paragraph mark formatted with 12 pt sapcing
afte. This works fine, but it also puts a border round the text, which I did
not actually specify.
However, when I looked at the macro, this is what I found:
Sub InsertSpacingAfter()
'
' InsertSpacingAfter Macro
' Replaces consecutive paras with 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 = wdFindAsk
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
End Sub

I am not au fait with VB, so how do I edit the macro so that it will not put
in the border, I tried just deleting 'Borders.Shadow, but it did not work.
Thank you,
 
G

Graham Mayor

Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find.Replacement.ParagraphFormat
.SpaceAfter = 12
End With
With Selection.Find
.Text = "^p^p"
.Replacement.Text = " ^p"
.Forward = True
.Wrap = wdFindAsk
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute replace:=wdReplaceAll

Will do what you want, but applying a spaced paragraph style to the text
would be more elegant than adding a manual paragraph format attribute.

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
G

Guest

Thank you, That worked.
I need the macro because I often get documents I have to format which have
two consecutiveparagraph marks to give spacing between paragraphs. Quite a
lot of people who use Word don't seem to know the use of Spacing After!
Thanks again
 

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