View Full Version : Solved: Username from Office/Excel
Derek
11-07-2005, 05:48 AM
Hi Folks
I am trying to write a function for the above. It seems simple but I am getting the answer #NAME? with the following code
Function GetName () As String
GetName = Application.UserName
End Function
in the cell I wish to have the username, I have typed =GetName. What am I doing wrong?:banghead:
malik641
11-07-2005, 05:52 AM
You forgot the parenthesis in your formula..try this:
=GetName()
That should do it :thumb
HTH
Derek
11-07-2005, 05:59 AM
Thanks for the reply but no, that has no effect. I just know this is going to be something simple. Any other ideas?:dunno
TonyJollans
11-07-2005, 06:29 AM
Where have you got your Function - it needs to be in a standard module, not in a sheet or workbook.
Bob Phillips
11-07-2005, 06:59 AM
Also, it would be better to use
GetName = Environ("UserName")
as this will get the login id. Application.Username could be anything.
Derek
11-07-2005, 08:11 AM
Thank you all, once again.
Missing parenthesis and not in a module. Once I changed those it worked a treat. I have checked it on a colleagues machine to ensure it changes to his Office user name and it works just fine.
Thank you, and in the words of Arnie, I'll be back!
:clap: :cloud9:
Ken Puls
11-07-2005, 03:57 PM
Hi guys,
Too late to help with this one, but I did submit an entry to the KB a while ago to do this. Actually it returns any one of three possibilities: Office username, Computer name or Windows login name.
Function to return various Environment Names
:)
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.