by Allen Wyatt
(last updated October 22, 2018)
Robert would like to have a macro that changes the gender of pronouns in documents and wonders if, perhaps, there is anything suggested to make such changes.
If you are looking for a macro to change the gender of all pronouns in a document, that is relatively straightforward—all you need is one that will do universal search and replace operations for male pronouns and change them to female pronouns, or vice-versa.
If, however, you are looking for a macro that will alternate pronouns—first usage is male, second is female, etc.—such as is often done in non-fiction writing, that is a different story. That is best left to a skilled editor to make the judgment calls on which changes to make and how far to extend those changes.
So, assuming you want to go the universal route, the best approach is to use a macro that utilizes wildcard searching using pairs of pronouns (one male pronoun with a corresponding female pronoun) to specify the changes to be made. The following example uses such an approach to change he, him, his, and himself to the female forms (she, her, hers, herself) or vice versa.
Sub MaleToFemale() GenderChange (True) End Sub
Sub FemaleToMale() GenderChange (False) End Sub
Sub GenderChange(isMale As Boolean) Dim aRange As Range Dim fTest As Boolean Dim j As Long Dim k As Long Dim male Dim female male = Array("he", "He", "HE", "him", "Him", "HIM", "his", _ "His", "HIS", "himself", "Himself", "HIMSELF") female = Array("she", "She", "SHE", "her", "Her", "HER", "hers", _ "Hers", "HERS", "herself", "Herself", "HERSELF") Set aRange = ActiveDocument.Range With aRange.Find .ClearFormatting .Replacement.ClearFormatting .Replacement.Highlight = False .Forward = True .Format = False .Wrap = wdFindStop .Format = False .Highlight = False .MatchCase = False .MatchWholeWord = False .MatchSoundsLike = False .MatchAllWordForms = False .MatchPrefix = False .MatchWildcards = True j = UBound(male) For k = 0 To j If isMale Then .Text = "<" & male(k) & ">" .Replacement.Text = female(k) Else .Text = "<" & female(k) & ">" .Replacement.Text = male(k) End If fTest = aRange.Find.Execute(Replace:=wdReplaceAll) Next k End With End Sub
Note that there are three macros in the listing. You should use the MaleToFemale macro to change from male pronouns to female pronouns and the FemaleToMale macro to change the other direction. The pronoun pairs themselves are in the GenderChange macro, in the male and female arrays. Note that each pronoun is included in the array three times using different combinations of upper- and lowercase characters. This is because the wildcard search is case sensitive, so the different searchs for each case instance is necessary.
Even with a macro approach like this (or especially with such an approach) it is wise to read through your document after using. The reason is because the English language is terribly imprecise and there is ambiguity in the usage of some words we generally consider pronouns. For instance, the words "his" and "hers" can be used as either possessive personal pronouns or as possessive adjectives. It is only possible to distinguish the proper usage when looking at them in context, which is something the macro obviously doesn't do. Bottom line—read after changing so you can make sure your document still makes sense.
WordTips is your source for cost-effective Microsoft Word training. (Microsoft Word is the most popular word processing software in the world.) This tip (12896) applies to Microsoft Word 2007, 2010, and 2013.
Do More in Less Time! Are you ready to harness the full power of Word 2013 to create professional documents? In this comprehensive guide you'll learn the skills and techniques for efficiently building the documents you need for your professional and your personal life. Check out Word 2013 In Depth today!
When creating macros, you often need to convert a text string that contains numbers into actual numeric values. You do ...Discover More
Want to grab some interactive input from a user in your macro? The best way to do that is with the InputBox function, ...Discover More
When using a macro to format text, you can set all sorts of attributes for paragraphs or individual characters. On ...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.