Welcome to Office Zealot Sign in | Join | Help

Word VBA: Function to get logged in user name

Figured I should follow my post on getting the user name in Excel with a flavor for Word. In the case of Word VBA, much is the same from the API standpoint but instead of a Function, I used a sub routine coupled with a Word varialbe and Field Code. Here it is below:

Sub UserNameWindows()
    UserNameWindows = Environ("USERNAME")
End Sub

Sub AddUserNameFieldCode()
    Selection.Fields.Add Range:=Selection.Range, Text:="DOCVARIABLE  UserNameWindows"
End Sub

Published Friday, December 10, 2004 12:51 PM by charles

Comments

No Comments

Anonymous comments are disabled