Please Note: This article is written for users of the following Microsoft Word versions: 2007, 2010, 2013, 2016, 2019, and Word in Office 365. If you are using an earlier version (Word 2003 or earlier), this tip may not work for you. For a version of this tip written specifically for earlier versions of Word, click here: Aligning Paragraphs in a Macro.
by Allen Wyatt
(last updated July 28, 2018)
Long-time Word users know that if you are formatting the paragraphs in your document, the Home tab of the ribbon includes some great tools you can use, or (better still) you can use styles to do the formatting. What if you have a need to align a paragraph within a macro you are writing, though? What do you do then?
Actually, aligning paragraphs within a macro is quite easy, requiring only a single line. Here's an example of how you would, for instance, center-align a paragraph:
Selection.ParagraphFormat.Alignment = wdAlignParagraphCenter
Notice that the Alignment property is set to a preset Word value, in this case wdAlignParagraphCenter. There are a number of different values you can use in your alignment:
WordTips is your source for cost-effective Microsoft Word training. (Microsoft Word is the most popular word processing software in the world.) This tip (12039) applies to Microsoft Word 2007, 2010, 2013, 2016, 2019, and Word in Office 365. You can find a version of this tip for the older menu interface of Word here: Aligning Paragraphs in a Macro.
Create Custom Apps with VBA! Discover how to extend the capabilities of Office 2013 (Word, Excel, PowerPoint, Outlook, and Access) with VBA programming, using it for writing macros, automating Office applications, and creating custom applications. Check out Mastering VBA for Office 2013 today!
Saving a document in a different format is easy if you are manually using the Save As command. Saving a document in an ...Discover More
The heart of creating powerful programs in VBA is to understand how to create subroutines. These structures allow you to ...Discover More
Do you need to do some simple math using dates in a your macro? One of the easy functions you can use is the DateDiff ...Discover More
FREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."
Got a version of Word that uses the ribbon interface (Word 2007 or later)? This site is for you! If you use an earlier version of Word, visit our WordTips site focusing on the menu interface.