#1   Report Post  
Misha
 
Posts: n/a
Default Macro

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,
  #2   Report Post  
Graham Mayor
 
Posts: n/a
Default

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
Word MVP web site http://word.mvps.org




Misha wrote:
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,



  #3   Report Post  
Misha
 
Posts: n/a
Default

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


"Graham Mayor" wrote:

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
Word MVP web site http://word.mvps.org




Misha wrote:
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,




Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
New macro in Word Ab Microsoft Word Help 2 January 26th 05 05:14 AM
Turning off Line Numbering Macro unformats my document! Victoria Page Layout 1 January 21st 05 12:34 AM
Save As is not working due to macro security settings Craig Meritz Microsoft Word Help 1 December 16th 04 03:53 AM
macro help tzap_1998 Microsoft Word Help 2 December 11th 04 11:40 PM
2000 to 2002 macro and "Could not open macro storage" Art Farrell Mailmerge 1 December 6th 04 12:40 PM


All times are GMT +1. The time now is 01:47 PM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"