Consulting

Results 1 to 4 of 4

Thread: Solved: Username not updating

  1. #1

    Solved: Username not updating

    Hi guys

    I've got a function for usernames, pretty basic:

    [VBA]
    Function getusername()
    getuser = (Environ$("Username"))
    getusername = getuser
    End Function
    [/VBA]

    and works fine when used in it's spreadsheet.

    So then I've got the formula ="Welcome "&getusername()

    Problem is, when the spreadsheet is e-mailed or opened on any other computer, it's not updating, so this thing is going all over the place with my name instead of the actual users name.

    I've tried putting in a calculate order when the workbook opens, calculation for the sheet is set to automatic and I'm now a bit as to why it's not updating itself.

    Any ideas?

    Phel

  2. #2
    VBAX Guru Kenneth Hobs's Avatar
    Joined
    Nov 2005
    Location
    Tecumseh, OK
    Posts
    4,956
    Location
    [vba]Application.Volatile[/vba]

    Environ("username") only gets that the environment variable value. This could be overridden. An API method would be more reliable. There is another method were we could get the Full Name or the given name which is just the first and last name.

  3. #3
    Quote Originally Posted by Kenneth Hobs
    [vba]Application.Volatile[/vba]
    That's my "something new learned" for today!

    Thanks Ken

    Edit - Curious about the other method you mentioned however regarding the proper names. Don't suppose you could point me in a direction to investigate further?
    Last edited by Phelony; 08-25-2011 at 07:04 AM.

  4. #4
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Quote Originally Posted by Kenneth Hobs
    Environ("username") only gets that the environment variable value. This could be overridden.
    Really? How?
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •