From: CJ on
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
From: Graham Mayor on
Use
If par.LineSpacingRule = wdLineSpaceExactly Then
or
If par.LineSpacingRule = 4 Then

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

My web site www.gmayor.com
Word MVP web site http://word.mvps.org
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>


"CJ" <CJ(a)discussions.microsoft.com> wrote in message
news:7272BD13-2EFA-4AB1-9DF5-2D856590F6B1(a)microsoft.com...
>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


From: Dorak on
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.

"Graham Mayor" wrote:

> Use
> If par.LineSpacingRule = wdLineSpaceExactly Then
> or
> If par.LineSpacingRule = 4 Then
>
> --
> <>>< ><<> ><<> <>>< ><<> <>>< <>><<>
> Graham Mayor - Word MVP
>
> My web site www.gmayor.com
> Word MVP web site http://word.mvps.org
> <>>< ><<> ><<> <>>< ><<> <>>< <>><<>
>
>
> "CJ" <CJ(a)discussions.microsoft.com> wrote in message
> news:7272BD13-2EFA-4AB1-9DF5-2D856590F6B1(a)microsoft.com...
> >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
>
>
> .
>
From: Graham Mayor on
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

My web site www.gmayor.com
Word MVP web site http://word.mvps.org
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>




"Dorak" <Dorak(a)discussions.microsoft.com> wrote in message
news:9A9D60CB-E40A-4F8E-960C-880FB5A24008(a)microsoft.com...
> 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.
>
> "Graham Mayor" wrote:
>
>> Use
>> If par.LineSpacingRule = wdLineSpaceExactly Then
>> or
>> If par.LineSpacingRule = 4 Then
>>
>> --
>> <>>< ><<> ><<> <>>< ><<> <>>< <>><<>
>> Graham Mayor - Word MVP
>>
>> My web site www.gmayor.com
>> Word MVP web site http://word.mvps.org
>> <>>< ><<> ><<> <>>< ><<> <>>< <>><<>
>>
>>
>> "CJ" <CJ(a)discussions.microsoft.com> wrote in message
>> news:7272BD13-2EFA-4AB1-9DF5-2D856590F6B1(a)microsoft.com...
>> >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
>>
>>
>> .
>>


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

"Graham Mayor" wrote:

> 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
>
> My web site www.gmayor.com
> Word MVP web site http://word.mvps.org
> <>>< ><<> ><<> <>>< ><<> <>>< <>><<>
>
>
>
>
> "Dorak" <Dorak(a)discussions.microsoft.com> wrote in message
> news:9A9D60CB-E40A-4F8E-960C-880FB5A24008(a)microsoft.com...
> > 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.
> >
> > "Graham Mayor" wrote:
> >
> >> Use
> >> If par.LineSpacingRule = wdLineSpaceExactly Then
> >> or
> >> If par.LineSpacingRule = 4 Then
> >>
> >> --
> >> <>>< ><<> ><<> <>>< ><<> <>>< <>><<>
> >> Graham Mayor - Word MVP
> >>
> >> My web site www.gmayor.com
> >> Word MVP web site http://word.mvps.org
> >> <>>< ><<> ><<> <>>< ><<> <>>< <>><<>
> >>
> >>
> >> "CJ" <CJ(a)discussions.microsoft.com> wrote in message
> >> news:7272BD13-2EFA-4AB1-9DF5-2D856590F6B1(a)microsoft.com...
> >> >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
> >>
> >>
> >> .
> >>
>
>
> .
>