Editing Paragraph Line Spacing using macro; need help

C

CJ

I have the following code which should, but does not, change paragraphs that
have exactly 24 or 12 pt spacing.

Can you advise me as to what is wrong with the code? I can't find anything
that addresses the issue in an if statement. I hope someone can help.

Sub ParaSpacingFix3()
'2. If the paras is set to exactly 12 points
' then make the spacing single spaced.
' If the paras is set to exactly 24 points
' then make the spacing double spaced.
Dim par As Paragraph

On Error GoTo NextPara

For Each par In ActiveDocument.Paragraphs
If par.LineSpacingRule = wdLineExactly Then
If par.LineSpacing = 24 Then
par.LineSpacingRule = wdLineSpaceDouble
ElseIf par.LineSpacing = 12 Then
par.LineSpacingRule = wdLineSpaceSingle
End If
End If

NextPara:
Next

End Sub
 
G

Graham Mayor

Use
If par.LineSpacingRule = wdLineSpaceExactly Then
or
If par.LineSpacingRule = 4 Then

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
D

Dorak

Thank you Graham for pointing out my typo. Works now. I'd love to be able to
refer to the linespacing rules values, how do I find out what the other ones
are.
 
G

Graham Mayor

The values are

wdLineSpaceSingle 0

wdLineSpace1pt5 1

wdLineSpaceDouble 2

wdLineSpaceMultiple 2

wdLineSpaceAtLeast 3

wdLineSpaceExactly 4



However using the names makes the macro easier to follow


--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
C

CJ

Thank you so much Graham, if I see the values like this in the future I will
have something to refer to.
 
K

Karl

CJ - I know this is an old post but I use a somewhat different to deal with line spacing using percentage rather than points:

ActiveDocument.Bookmarks("\page").Range.Select
With Selection.ParagraphFormat
.LineSpacing = LinesToPoints(0.95)
End With

You can also use other Objects such as

Const wdLineSpaceMultiple = 5

But I like percentage as I can make much finer adjustments.

- Karl
 
K

Karl

CJ - I know this is an old post but I use a somewhat different to deal with line spacing using percentage rather than points:

ActiveDocument.Bookmarks("\page").Range.Select
With Selection.ParagraphFormat
.LineSpacing = LinesToPoints(0.95)
End With

You can also use other Objects such as

Const wdLineSpaceMultiple = 5

But I like percentage as I can make much finer adjustments.

- Karl
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top