Normally, you add parentheses around your parenthetical remarks as you type your text. There may be times, however, when you want to add the parentheses at a later time. For instance, while editing your document you may select some text and then want parentheses added around the selected text. The following macro, AddParens, can be used to add the desired parentheses:
Sub AddParens() If Len(Selection.Range) > 0 Then Selection.InsertBefore "(" Selection.InsertAfter ")" Else MsgBox "No text was selected!" End If End Sub
The macro uses the InsertBefore and InsertAfter methods to add the appropriate parenthesis before and after the selected text.
To use the macro, assign it to a shortcut key or to a toolbar button. You then select the target text and invoke the macro. The desired parentheses are added to the text. (If you don't select any text before invoking the macro, you'll see a message box to that effect.)
Note:
WordTips is your source for cost-effective Microsoft Word training. (Microsoft Word is the most popular word processing software in the world.) This tip (11920) 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: Adding Parentheses.
The First and Last Word on Word! Bestselling For Dummies author Dan Gookin puts his usual fun and friendly candor back to work to show you how to navigate Word 2013. Spend more time working and less time trying to figure it all out! Check out Word 2013 For Dummies today!
If you need to find some synonyms for a specific word in your document, here's how you can do it. (Hint: All you need to ...
Discover MoreIf you have a group of people working on a single document, you may wonder what tools are available in Word to facilitate ...
Discover MoreOne of the most common symbols that can be added to a document is the copyright mark. This tip examines several ways you ...
Discover MoreFREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."
2018-10-19 13:29:17
Ben K.
How can this macro be modified to NOT enclose a trailing space after a word? I'd like the macro to check if the final character in the selection is a space, and if it is, put the closing parentheses to the left of the space.
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.
FREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."
Copyright © 2019 Sharon Parq Associates, Inc.
Comments