From: Tilds on 25 May 2010 07:59 Im trying to make a macro that set alignment on all text to wdAlignParagraphJustify, except text that is wdAlignParagraphCenter. Right now i have this: With ActiveDocument.Content.Find .ClearFormatting .ParagraphFormat.Alignment = wdAlignParagraphRight With .Replacement .ClearFormatting .ParagraphFormat.Alignment = wdAlignParagraphJustify End With .Execute Replace:=wdReplaceAll End With With ActiveDocument.Content.Find .ClearFormatting .ParagraphFormat.Alignment = wdAlignParagraphLeft With .Replacement .ClearFormatting .ParagraphFormat.Alignment = wdAlignParagraphJustify End With .Execute Replace:=wdReplaceAll End With This works, but I was hoping for a better solution since there apparently exists alot more alignment constants then those two. ActiveDocument.Content.Find.ParagraphFormat.Alignment <> wdAlignParagraphCenter doesnt work. /Niels
From: Graham Mayor on 25 May 2010 08:53 How about Dim oPara As Paragraph For Each oPara In ActiveDocument.Range.Paragraphs If oPara.Alignment <> wdAlignParagraphCenter Then oPara.Alignment = wdAlignParagraphJustify End If Next oPara -- <>>< ><<> ><<> <>>< ><<> <>>< <>><<> Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org <>>< ><<> ><<> <>>< ><<> <>>< <>><<> "Tilds" <Tilds(a)discussions.microsoft.com> wrote in message news:744517F6-EAA4-47DF-A9E9-10D7B16EC9C6(a)microsoft.com... > > Im trying to make a macro that set alignment on all text to > wdAlignParagraphJustify, except text that is wdAlignParagraphCenter. > > Right now i have this: > With ActiveDocument.Content.Find > .ClearFormatting > .ParagraphFormat.Alignment = wdAlignParagraphRight > With .Replacement > .ClearFormatting > .ParagraphFormat.Alignment = wdAlignParagraphJustify > End With > .Execute Replace:=wdReplaceAll > End With > With ActiveDocument.Content.Find > .ClearFormatting > .ParagraphFormat.Alignment = wdAlignParagraphLeft > With .Replacement > .ClearFormatting > .ParagraphFormat.Alignment = wdAlignParagraphJustify > End With > .Execute Replace:=wdReplaceAll > End With > > This works, but I was hoping for a better solution since there apparently > exists alot more alignment constants then those two. > ActiveDocument.Content.Find.ParagraphFormat.Alignment <> > wdAlignParagraphCenter > doesnt work. > > /Niels
From: Graham Mayor on 25 May 2010 09:02 On further reflection it will probably be necessary to refresh the screen to show the changes immediately, thus Dim oPara As Paragraph For Each oPara In ActiveDocument.Range.Paragraphs If oPara.Alignment <> wdAlignParagraphCenter Then oPara.Alignment = wdAlignParagraphJustify End If Next oPara Application.ScreenRefresh -- <>>< ><<> ><<> <>>< ><<> <>>< <>><<> Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org <>>< ><<> ><<> <>>< ><<> <>>< <>><<> "Graham Mayor" <gmayor(a)REMOVETHISmvps.org> wrote in message news:htgh7m$6vl$1(a)news.eternal-september.org... > How about > > Dim oPara As Paragraph > For Each oPara In ActiveDocument.Range.Paragraphs > If oPara.Alignment <> wdAlignParagraphCenter Then > oPara.Alignment = wdAlignParagraphJustify > End If > Next oPara > > > -- > <>>< ><<> ><<> <>>< ><<> <>>< <>><<> > Graham Mayor - Word MVP > > My web site www.gmayor.com > Word MVP web site http://word.mvps.org > <>>< ><<> ><<> <>>< ><<> <>>< <>><<> > > > > "Tilds" <Tilds(a)discussions.microsoft.com> wrote in message > news:744517F6-EAA4-47DF-A9E9-10D7B16EC9C6(a)microsoft.com... >> >> Im trying to make a macro that set alignment on all text to >> wdAlignParagraphJustify, except text that is wdAlignParagraphCenter. >> >> Right now i have this: >> With ActiveDocument.Content.Find >> .ClearFormatting >> .ParagraphFormat.Alignment = wdAlignParagraphRight >> With .Replacement >> .ClearFormatting >> .ParagraphFormat.Alignment = wdAlignParagraphJustify >> End With >> .Execute Replace:=wdReplaceAll >> End With >> With ActiveDocument.Content.Find >> .ClearFormatting >> .ParagraphFormat.Alignment = wdAlignParagraphLeft >> With .Replacement >> .ClearFormatting >> .ParagraphFormat.Alignment = wdAlignParagraphJustify >> End With >> .Execute Replace:=wdReplaceAll >> End With >> >> This works, but I was hoping for a better solution since there apparently >> exists alot more alignment constants then those two. >> ActiveDocument.Content.Find.ParagraphFormat.Alignment <> >> wdAlignParagraphCenter >> doesnt work. >> >> /Niels > >
|
Pages: 1 Prev: Vba excel add tables & shapes in word Next: Mystery of the Invisible Macros |