PDA

View Full Version : [SOLVED:] How do I get a line spacing of 1.0? The macros recorder does not work properly.



JohnLivewire
09-18-2017, 02:47 PM
I'm trying to get a line spacing of 1.0 using VBA but something is wrong with the macros recorder.



In the ribbon I click: Developer > Record Macro
To start recording, I click: ok
In the ribbon, I click: Home > Line and Paragraph Spacing > 1.0
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?

Kilroy
09-18-2017, 03:00 PM
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

JohnLivewire
09-18-2017, 06:05 PM
Is this the exact same thing?

gmaxey
09-18-2017, 08:41 PM
No it isn't.


Selection.ParagraphFormat.LineSpacing = LinesToPoints(1)

macropod
09-18-2017, 08:42 PM
The line height using wdLineSpaceSingle is the same as when using:

With .ParagraphFormat
.LineSpacingRule = wdLineSpaceMultiple
.LineSpacing = LinesToPoints(1)
End With

JohnLivewire
09-19-2017, 09:09 AM
thank you