?
Solved

Word 2007 VBA to check or uncheck "Don't add space between  paragraphs of the same style"

Posted on 2009-05-14
5
Medium Priority
?
2,213 Views
Last Modified: 2012-05-07
On the indents and spacing tab of the paragraph format dialog box, there is a checkbox called "Don't add space between  paragraphs of the same style".  What is the VBA code to check and uncheck this box?
0
Comment
Question by:TimLitle
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 76

Accepted Solution

by:
GrahamSkan earned 2000 total points
ID: 24396510
This sets the NoSpaceBetweenParagraphsOfSAmeStyle property of a particular Style:
Dim St as style
set st = ActiveDocument.Styles("Heading 1")
st.NoSpaceBetweenParagraphsOfSAmeStyle = False

Open in new window

0
 

Author Comment

by:TimLitle
ID: 24403972
I was able to make your code work when a style was involved but where I want to use it as shown in the code snippet below.  The Alignment property seems to work fine but the NoSpaceBetweenParagraphsOfSameStyle property is ignored even though the online VBA documentation for the Built-In Dialog wdDialogFormatParagraph box suggests that it should work.  Any suggestions?
rRange.ListFormat.ApplyListTemplate ListTemplate:=ltTemp     ' ltTemp applied to rRange with multiple paragraphs
rRange.Select
With Dialogs(wdDialogFormatParagraph)
    .NoSpaceBetweenParagraphsOfSameStyle = True   ' This line is ignored as written
    .Alignment = wdAlignParagraphLeft             ' This line is executed properly
    .Execute
End With

Open in new window

0
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 24405678
The property is available on the dialogue and in case it is relevant.

In the user interface it only works if you are formatting the paragraph of a style. It is otherwise greyed out in some versions of Word.

In code you would have to explicitly apply it to the style(s) that you wanted to modify.
0
 

Author Comment

by:TimLitle
ID: 24418224
It took a little while to figure out what Style Name I shoulf use and when I did, I spelled it incorrectly.  I'v now got it right and the code works as expected.  thanks for your help.
0
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 24419602
Thanks Tim,
Glad you worked it out.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preface: When I started this series, I used the term CommandBars because that is the Office Object class that it discusses. Unfortunately, when Microsoft introduced Office 2007, they replaced the standard Commandbar menus with "The Ribbon" and rem…
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
This video walks the viewer through the process of creating envelopes and labels, with multiple names and addresses. Navigate to the “Start Mail Merge” button in the Mailings tab: Follow the step-by-step process until asked to find the address doc…
Office 365 is currently available in five editions. Three of them are for business use: Office 365 Business Essentials, Office 365 Business, and Office 365 Business Premium. Two of them are for home/personal use: Office 365 Home and Office 365 Perso…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question