Our Blog

Swapping User Names

by | Aug 10, 2019 | , | Tools of the Trade | 0 comments

I have a client who wants the user name that appears in my Microsoft Word comments and revisions to match the level of editing being done. For example, in a document I am copyediting my user name should read “copyeditor” and in a document I am proofreading it should read “proofreader.” Manually changing the user name when I switch between documents doesn’t take a lot of time, but it is a bit of a pain to do repeatedly. The manual change also creates the opportunity for misspellings and inconsistencies to creep in.

Figure 1: Each time the macro is run, Word’s user name is set to the next name in the series

To automate changing the user name, I created a macro that steps through a series of names and assigns the next name in the series each time the macro is run. (It also changes the user initials.) After the last name has been assigned, the macro starts again with the first name in the series. Editing the user names in the series involves a little adjustment of the macro’s code but is not too complicated.

Using the Macro

The version of the macro presented below has four user-name-and-initial options. Each time the macro is run, the user name will be updated to the next name in the series and this new user name will appear in the Word status bar (in the lower left corner of the screen) until a key or mouse button is pressed. If you would also like to have a pop-up dialogue box display the updated name, delete the apostrophe in the second to last line, before “MsgBox.”

Manually entering a user name in Word will not affect the way the macro works. If a user name that is not part of the series has been manually entered, the first user name in the series (in this case, “Dev Editor”) will be substituted when the macro is run. While the macro sets user initials, it doesn’t check to see if they have been manually edited. Any manual edits of user initials will be overwritten when the macro is run.

I assign this macro to the keyboard shortcut Alt + u to make it easier to run. If you would like to have this macro automatically add that shortcut, delete the apostrophe in the second line, before “KeyBindings.” You will have to run the macro once manually before the shortcut will be set.

Customizing the User Names

You will likely want to edit the series of user names. This involves a little adjustment of the “case” commands in the macro but is not too complicated of a process. The steps are as follows.

Determine how long of a series you want. To remove a name from the series, delete one set of three lines: a line beginning with “Case” and the following two lines that begin “NewName” and “NewInitials.” Don’t delete the final “Case Else” statement, though. To add a name to the series, duplicate the three lines mentioned above and place them before the final “Case Else” section.

Adjust the user names and initials. On the lines beginning  with “NewName” and “NewInitials” change the text in quotes to the desired user name and initials. Then set the name in the first line that starts with “Case” to match the “NewName” field in the “Case Else” section. Finally, change the name in each of the other “Case” lines to match the “NewName” field in the section that precedes it.


 The Code

Sub Swap_User_Names()
     'KeyBindings.add wdKeyCategoryMacro, "Swap_User_Names", BuildKeyCode(wdKeyAlt, wdKeyU)
     OldName = Application.UserName
     Select Case OldName
         Case "Dev Editor"
             NewName = "Copyeditor"
             NewInitials = "CE"
         Case "Copyeditor" 
             NewName = "Proofreader"
             NewInitials = "PR"
         Case "Proofreader" 
             NewName = "Cold Reader"
             NewInitials = "CR"
         Case Else
             NewName = "Dev Editor"
             NewInitials = "DE"
     End Select
     Application.UserName = NewName
     Application.UserInitials = NewInitials
     StatusBar = "User Name is now " & NewName
     'MsgBox ("User Name is now " & NewName)
 End Sub

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

Share This