How to lock the user name?

SwordAngel

New Member
Joined
Aug 2, 2009
Messages
11
Hello!

Those of you who have used the "share workbook" and/or "track changes" features of Excel probably know that it is possible to set a user name at each computer so that people can easily see who changed what. This seems like a useful feature, but I have not found any information regarding how a computer administrator can prevent the computer user to change his/her user name. If the administrator cannot prevent normal users from changing the user name, then this user name would be useless in assuring accountability.

Is it at all possible to lock the user name?
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
This should work, unless the user disables macros.


Code:
Private Sub Workbook_Open()

Application.UserName = Environ("UserName")

End Sub

Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)

Application.UserName = Environ("UserName")

End Sub
 
Last edited:
Upvote 0
This should work, unless the user disables macros.


Code:
Private Sub Workbook_Open()

Application.UserName = Environ("UserName")

End Sub

Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)

Application.UserName = Environ("UserName")

End Sub

Heh, that begs the question: how do I prevent the users from disabling macro?

:rolleyes:
 
Upvote 0
you can't prevent someone from disabling macros (it's a security feature for a user's protection against bad macros).

you can however force someone to enable macros by hiding the worksheet and putting an workbook open event that unhides the worksheet (i.e. macro-disabled users will not see the sheet because the code doesn't run to unhide the sheet).

In a shared workbook, however, this may not work since as soon as someone enables macros and unhides the worksheet, any subsequent users (both macro-enabled and macro-disabled users) will be able to see that sheet when they open the workbook.

Perhaps you could protect the worksheet entirely and only allow input/changes through a userform that opens with an workbook open event.

sorry, there's no easy solution here.
 
Upvote 0

Forum statistics

Threads
1,214,919
Messages
6,122,260
Members
449,075
Latest member
staticfluids

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top