Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 04-01-2015, 11:06 AM
jjmclell jjmclell is offline Allowing space between paragraphs of same style Windows 7 32bit Allowing space between paragraphs of same style Office 2010 32bit
Advanced Beginner
Allowing space between paragraphs of same style
 
Join Date: Nov 2012
Location: Sault Ste. Marie, Canada
Posts: 52
jjmclell is on a distinguished road
Default Allowing space between paragraphs of same style

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
Reply With Quote
  #2  
Old 04-01-2015, 10:35 PM
gmayor's Avatar
gmayor gmayor is offline Allowing space between paragraphs of same style Windows 7 64bit Allowing space between paragraphs of same style Office 2010 32bit
Expert
 
Join Date: Aug 2014
Posts: 4,101
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

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
Reply With Quote
  #3  
Old 04-02-2015, 06:03 AM
jjmclell jjmclell is offline Allowing space between paragraphs of same style Windows 7 32bit Allowing space between paragraphs of same style Office 2010 32bit
Advanced Beginner
Allowing space between paragraphs of same style
 
Join Date: Nov 2012
Location: Sault Ste. Marie, Canada
Posts: 52
jjmclell is on a distinguished road
Default

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.
Reply With Quote
  #4  
Old 04-02-2015, 06:29 AM
gmayor's Avatar
gmayor gmayor is offline Allowing space between paragraphs of same style Windows 7 64bit Allowing space between paragraphs of same style Office 2010 32bit
Expert
 
Join Date: Aug 2014
Posts: 4,101
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

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
Reply With Quote
  #5  
Old 04-02-2015, 06:44 AM
jjmclell jjmclell is offline Allowing space between paragraphs of same style Windows 7 32bit Allowing space between paragraphs of same style Office 2010 32bit
Advanced Beginner
Allowing space between paragraphs of same style
 
Join Date: Nov 2012
Location: Sault Ste. Marie, Canada
Posts: 52
jjmclell is on a distinguished road
Default

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.
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Allowing space between paragraphs of same style Style affecting other paragraphs around the word I'm trying to change. 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

Other Forums: Access Forums

All times are GMT -7. The time now is 11:02 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft