+ Reply to Thread
Results 1 to 6 of 6

Get Username - but only once

  1. #1
    Forum Contributor
    Join Date
    01-11-2011
    Location
    Frederick, MD, USA
    MS-Off Ver
    Excel 2007
    Posts
    125

    Get Username - but only once

    So, I've cribbed some VBA code to pull the login name of the user into a workbook. (I readily admit that I copied this from another site, as I really have no clue when it comes to VBA.)

    This code works a treat for getting the username, and I simply add the formula "=windowsusername()" into whatever cell I want to have it populate.

    However, if a different user opens the worksheet, it then changes the result. (That is, if "aliceanders" opens the doc first, then saves it and send it to "bobbrewer", when Bob opens it, the user will be "bobbrewer".)

    Question: how can I get this to only update the cell the first time someone opens the document?

    The VBA I'm using:

    Please Login or Register  to view this content.

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Get Username - but only once

    What does "the first time someone opens the document" mean?

    The person that created it is the first person to have it open.
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Forum Contributor
    Join Date
    01-11-2011
    Location
    Frederick, MD, USA
    MS-Off Ver
    Excel 2007
    Posts
    125

    Re: Get Username - but only once

    I should have explained that the worksheet I'm creating is to be used as a template for others. So, yeah...I'll be the first one opening it, and it will default to my username, then. Is there a way to save it in a 'blank' state, perhaps, and then have it update, once only, the next time it is opened?

    Or, perhaps, some way of stating "the next time this particular cell is modified, lock it down"?

  4. #4
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Get Username - but only once

    Maybe (untested)
    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    01-11-2011
    Location
    Frederick, MD, USA
    MS-Off Ver
    Excel 2007
    Posts
    125

    Re: Get Username - but only once

    Shoot...I need to get in the practice of stating all my restrictions on these, too. Because the ultimate template will actually be launched from another program that gets a little finicky, I am restricted from using anything that activates upon open of the worksheet, as it appears this one does. I'm still testing whether "on activate" of a particular worksheet will work, but I doubt it will. (I've heard that "on modification" of a certain cell is possible, but I can't find the way to write that, and I'm not certain it would work in this instance anyway; I understand that requires an active modification of a cell, which this would not be.)

  6. #6
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Get Username - but only once

    Create it as a proper template
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1