Please Note: This article is written for users of the following Microsoft Word versions: 2007, 2010, 2013, 2016, 2019, and Word in Microsoft 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.
Written by Allen Wyatt (last updated July 28, 2018)
This tip applies to Word 2007, 2010, 2013, 2016, 2019, and Word in Microsoft 365
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 Microsoft 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!
If you know how to create macros, you can easily create entire replacements for Word's internal commands. Here's all you ...Discover More
Want to turn off document repagination while your macro does its work? Here are two approaches you can use.Discover More
When working with macros, you may want to create a variable that will remain constant from one instance of the macro to ...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.
Visit the WordTips channel on YouTube