VBA Code for Centering a Line
Report abuse
Thank you.
Reported content has been submitted

No. If you want to use VBA to set the alignment of a paragraph, you would use:
Selection.Paragraphs(1).Alignment = wdAlignParagraphCenter
From the VBA help file for Alignment
Paragraph.Alignment Property (Word)
Returns or sets a WdParagraphAlignment constant that represents the alignment for the specified paragraphs. Read/write.
expression.Alignment
expression Required. A variable that represents a Paragraph object.
Some of the WdParagraphAlignment constants, depending on the language support (U.S. English, for example) that you've selected or installed.
This example right-aligns the first paragraph in the active document.
VBA |
---|
Sub AlignParagraph() ActiveDocument.Paragraphs(1).Alignment = wdAlignParagraphRight End Sub |
Doug Robbins - MVP Office Apps & Services (Word)
dougrobbinsmvp@gmail.com
Report abuse
Thank you.
Reported content has been submitted
Was this reply helpful?
Sorry this didn't help.
Great! Thanks for your feedback.
How satisfied are you with this reply?
Thanks for your feedback, it helps us improve the site.
How satisfied are you with this reply?
Thanks for your feedback.
Question Info
Last updated October 5, 2021 Views 104 Applies to: