Consulting

Results 1 to 6 of 6

Thread: How do I get a line spacing of 1.0? The macros recorder does not work properly.

  1. #1

    Exclamation How do I get a line spacing of 1.0? The macros recorder does not work properly.

    I'm trying to get a line spacing of 1.0 using VBA but something is wrong with the macros recorder.


    1. In the ribbon I click: Developer > Record Macro
    2. To start recording, I click: ok
    3. In the ribbon, I click: Home > Line and Paragraph Spacing > 1.0
    4. In the ribbon, I click: Developer > Stop Recording


    This is the VBA code I got from that recording:
    Sub Macro1()
    '
    ' Macro1 Macro
    '
    '
        Selection.ParagraphFormat.LineSpacing = LinesToPoints(32888)
    End Sub
    When I try to run that code. I get a pop up window with this error message:

    Run-time error '5149':

    The measurement must be between 0.7 pt and 1584 pt.


    How do I get a line spacing of 1.0 using VBA?
    Last edited by JohnLivewire; 09-18-2017 at 06:13 PM.

  2. #2
    VBAX Tutor
    Joined
    Jul 2016
    Posts
    266
    Location
    This is what I use.


    Sub linespacing()
    Selection.WholeStory
    With Selection.ParagraphFormat
    .SpaceBefore = 1
    .SpaceBeforeAuto = False
    .SpaceAfter = 1
    .SpaceAfterAuto = False
    .LineSpacingRule = wdLineSpaceSingle
    .LineUnitBefore = 0
    .LineUnitAfter = 0
    End With
    End Sub

  3. #3
    Is this the exact same thing?

  4. #4
    Microsoft Word MVP 2003-2009 VBAX Guru gmaxey's Avatar
    Joined
    Sep 2005
    Posts
    3,344
    Location
    No it isn't.

    Selection.ParagraphFormat.LineSpacing = LinesToPoints(1)
    Greg

    Visit my website: http://gregmaxey.com

  5. #5
    VBAX Guru macropod's Avatar
    Joined
    Jul 2008
    Posts
    4,435
    Location
    The line height using wdLineSpaceSingle is the same as when using:
    With .ParagraphFormat
        .LineSpacingRule = wdLineSpaceMultiple
        .LineSpacing = LinesToPoints(1)
    End With
    Cheers
    Paul Edstein
    [Fmr MS MVP - Word]

  6. #6
    thank you

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •