Share via

VBA Syntax for Paragraph Spacing using Bullets

Anonymous
2017-03-21T19:09:47+00:00

Hello,

I am writing code to produce a document. Each paragraph within each section is numbered with bullets.  I would like to add a 12 pt space after each paragraph.  

To do this manually, you would set up your bullets as normal and then select the paragraph options on the Home ribbon. From the paragraph dialog box, under spacing, you need to un-select the "Don't add space between paragraphs of the same style" checkbox.

Can someone tell me how to do this using VBA code? I have figured out how to get the numbered bullets. Just can't seem to get the spacing between paragraphs. 

Thanks in advance.

Microsoft 365 and Office | Word | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

Stefan Blom 342.4K Reputation points MVP Volunteer Moderator
2017-03-21T20:05:27+00:00

The option to suppress Spacing Before/After for paragraphs of the same style is controlled by the NoSpaceBetweenParagraphsOfSameStyle property in the Style object. It only applies to Style objects that are paragraph styles. For example, the following code turns off the option for the Normal style:

ActiveDocument.Styles(wdStyleNormal).NoSpaceBetweenParagraphsOfSameStyle = False

Was this answer helpful?

1 person found this answer helpful.
0 comments No comments

3 additional answers

Sort by: Most helpful
  1. Stefan Blom 342.4K Reputation points MVP Volunteer Moderator
    2017-03-22T19:36:27+00:00

    Yes, the name of the style in my code sample was just an example, as you figured out.

    It is worth noting that many styles, but not all of them, have an associated wdStyle constant.

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2017-03-22T19:32:53+00:00

    Never mind Stefan,

    I figured it out. I changed wdStyleNormal to wdStyleListParagraph and it seems to be working. 

    Much thanks

    Was this answer helpful?

    0 comments No comments
  3. Anonymous
    2017-03-22T18:46:55+00:00

    Stefan,

    Unfortunately, that didn't work. The issue may be with how I am adding my bullets in the first place.  I just recorded the steps and then changed the indentions to suit my needs.   Here's my code. I've added your suggestion in several places but none seem to get the results I'm looking for. (and I'm sure a lot of this can be removed, which I'll do line by line once I figure out what I actually need.)

    Code*******************************************************

        ListGalleries(wdNumberGallery).ListTemplates(1).Name = ""

        Selection.Range.ListFormat.ApplyListTemplateWithLevel ListTemplate:= _

            ListGalleries(wdNumberGallery).ListTemplates(1), ContinuePreviousList:= _

            False, ApplyTo:=wdListApplyToWholeList, DefaultListBehavior:= _

            wdWord10ListBehavior

        With Selection.ParagraphFormat

            .LeftIndent = InchesToPoints(0.5)

            .RightIndent = InchesToPoints(0)

            .SpaceBefore = 0

            .SpaceBeforeAuto = False

            .SpaceAfter = 12

            .SpaceAfterAuto = False

            .LineSpacingRule = wdLineSpaceSingle

            .Alignment = wdAlignParagraphLeft

            .WidowControl = True

            .KeepWithNext = False

            .KeepTogether = False

            .PageBreakBefore = False

            .NoLineNumber = False

            .Hyphenation = True

            .FirstLineIndent = InchesToPoints(-0.5)

            .OutlineLevel = wdOutlineLevelBodyText

            .CharacterUnitLeftIndent = 0

            .CharacterUnitRightIndent = 0

            .CharacterUnitFirstLineIndent = 0

            .LineUnitBefore = 0

            .LineUnitAfter = 0

            .MirrorIndents = False

            .TextboxTightWrap = wdTightNone

            .CollapsedByDefault = False

        End With

        ActiveDocument.Styles(wdStyleNormal).NoSpaceBetweenParagraphsOfSameStyle = True

        Selection.TypeText Text:= _

            "blah blah blah"

        Selection.TypeParagraph

        Selection.TypeText Text:="blah blah blah"

        Selection.TypeParagraph

        Selection.TypeText Text:="blah blah blah"

        Selection.TypeParagraph

    Was this answer helpful?

    0 comments No comments