View Full Version : Add a new paragraph after for each selected paragraph
smallxyz
07-25-2016, 05:18 AM
Hi,
Suppose there are 3 paragraphs:
*********
******
******************
After highlighting them, the VBA would return :
*********
******
******************
Below is my attempted code, but it returns infinite parapraphs.
Private Sub cmdLnBr_Click()
Dim P As Paragraph
Application.ScreenUpdating = False
For Each P In Selection.Paragraphs
P.Range.InsertParagraphAfter
Next
Unload Me
End Sub
How should I amend it?
Thanks.
gmayor
07-25-2016, 09:43 PM
It would make far more sense to add spacing to the paragraphs than to add empty paragraphs.
Selection.ParagraphFormat.SpaceAfter = 12Or better still create a paragraph style in the template/document with the spacing you require and apply it to the selection. e.g.
Selection.Style = "Stylename"Empty paragraphs are used by typewriters. Wordprocessors use spacing which makes subsequent editing far more simple. However if you insist
Dim lngPara As Long
For lngPara = Selection.Paragraphs.Count To 1 Step -1
Selection.Paragraphs(lngPara).Range.InsertParagraphAfter
Next lngPara
smallxyz
07-26-2016, 02:18 AM
It would make far more sense to add spacing to the paragraphs than to add empty paragraphs.
Selection.ParagraphFormat.SpaceAfter = 12Or better still create a paragraph style in the template/document with the spacing you require and apply it to the selection. e.g.
Selection.Style = "Stylename"Empty paragraphs are used by typewriters. Wordprocessors use spacing which makes subsequent editing far more simple. However if you insist
Dim lngPara As Long
For lngPara = Selection.Paragraphs.Count To 1 Step -1
Selection.Paragraphs(lngPara).Range.InsertParagraphAfter
Next lngPara
Thank you gmayor!
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.