Written by Allen Wyatt (last updated October 16, 2021)
This tip applies to Word 2007, 2010, 2013, 2016, 2019, and Word in Microsoft 365
Nathan frequently runs across a problem with individuals capitalizing job titles (e.g., "The Finance Manager shall provide...") in documents. He would like a macro to check for every use of a managerial title and lowercase it, unless there is a valid reason to initial-cap the first word when the title begins a sentence. He wonders if it is possible, without inputting all thirty managerial titles, to set up a wild card to match any two-word phrase where the second word is "manager" or "managers."
It is possible to do a wild card search to find the types of instances you are seeking. All you need to do is do an advanced search, make sure the Use Wildcards check box is selected, and then use this pattern in the Find What field:
<[A-Za-z][a-z]{1,}>^32[Mm]anager*>
The pattern will find two words where the second word is manager or managers. It will find the words if both or either word is capitalized or both words are in lowercase.
The problem is that it is not possible to change a word that has been found using wildcards to all lower case. This means that you'll need to manually inspect what is found and then make any necessary changes by hand. If you only have to do this once in a while, that isn't too onerous because the Find and Replace dialog box is not modal. (That means you can leave the dialog box open on your screen as you make an edit in the document, then click Find Next in the dialog box to find the next matching occurrence.)
If you need to do such changes quite often, then the only alternative is to create a macro that will do the changes for you. The following macro searches for the same pattern noted above and then correctly changes the capitalization of job titles. The macro finds job titles comprised of two words with the second word being "manager," "Manager," "managers" or "Managers." It then removes any capitalization from the words unless the title starts a sentence in which case it only removes capitalization from the second word.
Sub FixManagerCapitalisation() Dim aRange As Range Dim bRange As Range With Selection.Find .ClearFormatting .Text = "<[A-Za-z][a-z]{1,}>^32[Mm]anager*>" .Replacement.Text = "" .Forward = True .Wrap = wdFindAsk .MatchCase = False .MatchWildcards = True Do While .Execute Set aRange = Selection.Range Set bRange = Selection.Range bRange.MoveEnd unit:=wdSentence If bRange.Text <> Selection.Sentences(1).Text Then aRange = LCase(aRange.Words(1).Text) & Trim(aRange.Words(2)) End If aRange = aRange.Words(1) & Trim(LCase(aRange.Words(2).Text)) aRange.Start = aRange.End aRange.Select .ClearFormatting Loop End With End Sub
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 (13080) applies to Microsoft Word 2007, 2010, 2013, 2016, 2019, and Word in Microsoft 365.
Comprehensive VBA Guide Visual Basic for Applications (VBA) is the language used for writing macros in all Office programs. This complete guide shows both professionals and novices how to master VBA in order to customize the entire Office suite for their needs. Check out Mastering VBA for Office 2010 today!
It is a good idea to make sure that the spacing following each sentence in your document is consistent. Here's a handy ...
Discover MoreNeed an em dash to be "sticky" on both ends of the dash? Word doesn't provide such formatting, but there are a few ...
Discover MoreTake a look in a dictionary at the way that words are phonetically spelled. Those special characters used to type those ...
Discover MoreFREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."
There are currently no comments for this tip. (Be the first to leave your comment—just use the simple form above!)
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
FREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."
Copyright © 2024 Sharon Parq Associates, Inc.
Comments