update user name in excel on open

  • Thread starter Thread starter fishy
  • Start date Start date
F

fishy

We have a standard build on our PC's that returns a generic user on excel if
people havent updated their User Name details in the 'Tools', 'Options',
'General' tab.

I want to be able to capture the users NT logon and write this to the user
name field in excel so that it stores this permanantly whenever they open
this workbook.

I have tried to google etc but cant see anything that updates this field but
loads that store the username in the book.
 
From workbook press Alt+F11 to launch VBE (Visual Basic Editor). From the
left treeview search for the workbook name and click on + to expand it.
Within that you should see the following

VBAProject(Your_Filename)
Microsoft Excel Objects
Sheet1(Sheet1)
Sheet2(Sheet2)
Sheet3(Sheet3)
This Workbook

Double click 'This WorkBook' and paste the below code to the right code pane.

Private Sub Workbook_Open()
Application.UserName = Environ("Username")
End Sub
 
Back
Top