How to automaticaly insert user name (login name) in excel?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I wish to add a signature line on an Excel document that automatically reads
the users name from either the login or document properties. is this
possible? this will be a template for 40 users and would like to automate as
much as possible.

thanks,
 
With this function in a Module

Public Function LastAuthor() As String
Application.Volatile
LastAuthor = _
ThisWorkbook.BuiltinDocumentProperties("Last Author")
End Function

The formula =LastAuthor() in any cell will return the LastAuthor's name,
providing the file has been previously saved.

Vaya con Dios,
Chuck, CABGx3
 
Try this one line UDF:

Public Function user() As String
user = Environ("username")
End Function
 
I am a bit green w/ programming. I may need a bit of a walk through. Do I
just create this as a Macro and edit into the VB module... If i have this doc
saved as a template by the Admin, does the "Last Author" recover the Admin as
previously saved? does this change when the user "saves as" to a new name?

I am also intending to have a second line containing the users email
address. can I create some kind of formula to auto fill this info from a
retrieved string and a list of address?

Thanks,
Dave
 
I am a bit green w/ programming. I may need a bit of a walk through. Do I
just create this as a Macro and edit into the VB module... Does the
"username" string draw from the system login name?
I am also intending to have a second line containing the users email
address. can I create some kind of formula to auto fill this info from a
retrieved string and a list of address?

Thanks,
Dave
 
Actually, Gary"s Student's function is slicker than mine. It doesn't require
the file be saved either............just copy and paste it into a regular VBA
module, and then just enter =User() in whatever cell you wish the User's name
to appear........

Vaya con Dios,
Chuck, CABGx3
 
Thanks,

That did the job.. although it doesn't automatically update unless I access
the cell. w/ a little function work I got the matching to user and email
address to work and created a simple macro to auto activate the cell.
thanks again.

I have another post out here that maybe you could give a quick shot at...
same project, i have a Word doc. inserted as an object for a comment field.
if i protect the sheet I cannot edit the doc. If I unlock the object and
protect the sheet, I can edit the doc but it can be accidentally moved. Is
there a way to lock position w/out locking entire object?

thanks,
Dave
 
Back
Top