From: CJ on 23 Feb 2010 09:55 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 23 Feb 2010 10:50 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 23 Feb 2010 16:04 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 24 Feb 2010 02:31 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 24 Feb 2010 09:46 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 > >> > >> > >> . > >> > > > . >
|
Pages: 1 Prev: Auto jump to the next field Next: Making a UserForm show above a any opened doc |