![]() |
#1
|
|||
|
|||
![]()
I'm trying to create a simple macro that I can assign to a button where I allow space between paragraphs of the same style and then add a 6pt space after the paragraph. I've tried the following, but I can't get Word to allow space between paragraphs:
Code:
Sub LineSpacing6pt() Selection.Style.NoSpaceBetweenParagraphsOfSameStyle = False Selection.ParagraphFormat.SpaceAfter = 6 End Sub |
#2
|
||||
|
||||
![]()
Don't use a macro for this. Create (or modify) a paragraph style to include the formatting you require and add it to the quick styles list.
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
#3
|
|||
|
|||
![]()
The reason I was trying to create a macro for adjusting paragraph spacing is because I have to work on docs I didn't create, meaning they were created based on somebody else's Normal template and the styles aren't set when I get the doc, and it would be nice if I didn't have to set styles everytime I have to work on a doc.
If I create a macro, it seems I can call on it regardless of where the doc comes from. |
#4
|
||||
|
||||
![]()
OK, I tried
![]() Code:
Sub LineSpacing6pt() Dim opara As Paragraph Dim i As Long For i = 1 To Selection.Range.Paragraphs.Count Set opara = Selection.Range.Paragraphs(i) opara.Range.Style.NoSpaceBetweenParagraphsOfSameStyle = False opara.Range.ParagraphFormat.SpaceAfter = 6 Next i lbl_Exit: Exit Sub End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
#5
|
|||
|
|||
![]()
Appreciate it. I will look at your code. I tested out some other ideas as well, so I think I have enough info to call this one resolved.
I think in my first example, I probably was toggling the nospacebetweenparagraphsofsamestyles attribute, but was applying the paragraph spacing I wanted to the paragraph rather than the style and one was over-riding the other...or something like that. I got it working in a test doc this morning. First crack at VBA in Word... Thanks. |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
Bahamut5098 | Word | 2 | 03-02-2015 01:42 PM |
Delete lots of empty space between paragraphs. | FieldTechnician | Word | 4 | 10-25-2013 01:14 PM |
Don't add space between para of the same style | ghumdinger | Word | 3 | 09-19-2011 02:04 AM |
Don't Add Space between paragraphs option | Emerogork | Outlook | 12 | 07-18-2011 10:01 AM |
Space between paragraphs... | Emerogork | Outlook | 2 | 06-24-2011 10:23 AM |