VBA to switch between User Names?

Hi there,

I am administrating documents using track changes to display changes that I make and changes that come from other sources. I am making all the changes and my User name is displayed.

I would like to use a different user name for the "external changes", I know change of user name can be done manually, but it will be tedious going back and forth.

So is there a way to make script to switch between my user name and a custom one to apply for external changes?

 

Inputs much appreciated!

Answer
Answer
The following macro should toggle between the two names

Sub ToggleUser()
If Application.UserName = "Viggo Linde" Then
    Application.UserName = "Some Other Name"
Else
    Application.UserName = "Viggo Linde"
End If
ActiveDocument.Fields.Update
End Sub
Graham Mayor (Microsoft Word MVP 2002-2019)
For more Word tips and downloads visit my web site
https://www.gmayor.com/Word_pages.htm

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

Answer
Answer

You could create the following macro in a module in your default template Normal.dotm:

 

Sub ToggleUser()
    If Application.UserName = "Anne Roe" Then
        Application.UserName = "John Doe"
    Else
        Application.UserName = "Anne Roe"
    End If
    MsgBox "Username is now " & Application.UserName, vbInformation
End Sub

 

Change the usernames to suit your purpose.

 

You can assign the macro to a button on the Quick Access toolbar and/or to a custom keyboard shortcut, to make it easily available.

---
Best wishes, HansV
https://www.eileenslounge.com

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

 
 

Question Info


Last updated September 28, 2023 Views 872 Applies to: