Username

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

Guest

Hi All

Like the new view of the website!

In MS Access there is a formula =currentuser() which gives the username of the person logged into the database, is there an equivalent in MS Excel? I know you can't log into Excel but i was hoping it could pick up the users windows login or email address or something...

I want to personalise my Excel forms so they firstly, say hi to the person who has opened it (read only) and also changes the formats, data etc based on who it is

Is there any way to do this

Thank
Emma
 
Hi
application.username

--
Regards
Frank Kabel
Frankfurt, Germany

Emma said:
Hi All,

Like the new view of the website!!

In MS Access there is a formula =currentuser() which gives the
username of the person logged into the database, is there an equivalent
in MS Excel? I know you can't log into Excel but i was hoping it could
pick up the users windows login or email address or something....
I want to personalise my Excel forms so they firstly, say hi to the
person who has opened it (read only) and also changes the formats, data
etc based on who it is.
 
Emma,

There is no formula, but you can create your own in VBA

Function UserName()
UserName = CreateObject("WScript.Network").UserName
End Function

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

Emma said:
Hi All,

Like the new view of the website!!

In MS Access there is a formula =currentuser() which gives the username of
the person logged into the database, is there an equivalent in MS Excel? I
know you can't log into Excel but i was hoping it could pick up the users
windows login or email address or something....
I want to personalise my Excel forms so they firstly, say hi to the person
who has opened it (read only) and also changes the formats, data etc based
on who it is.
 
...
...
There is no formula, but you can create your own in VBA

Function UserName()
UserName = CreateObject("WScript.Network").UserName
End Function
...

Two quibbles. First, this puts a lot of faith in VBA's garbage collection, that
it'll implicitly discard the created object and free up its memory. Maybe this
always works well in VBA. Second, I wonder about the performance of object
creation vs straight API calls. One alternative is the fOSUserName function,
which has been around for a while.

http://www.google.com/[email protected]
 
Long time no hear Harlan,

As regards garbage collection, I used to have much the same take on it as
you seem to have. I once read the following post on Google from no less
than Matt Curland
http://www.google.com/groups?&selm=ek3bQmPdAHA.1808@tkmsftngp03 whereby he
railed against the lack of faith. Whilst I am sure there is scepticism
around from any statement from Redmond or its employees, this guy was
involved in building this, and warrants listening to.

As to API v object creation, I used to use the API method for username, and
have just recently switched to the latter. The latter is certainly shorter,
can be recalled from memory, and as to performance, well we'll not resurrect
our many discussions on this from the past, but I would venture that it
would a rare application whereby the logged on user becomes a performance
issue.

Regards

Bob
 
Final comment. API calls are guaranteed to work unless the OS files
themselves have become fubar. Windows Script Host is an *optional*
component.
 
Back
Top