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

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.

crimson_b1ade

Well-known Member
Joined
Sep 27, 2008
Messages
1,557
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:

SwordAngel

New Member
Joined
Aug 2, 2009
Messages
11
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:
 

crimson_b1ade

Well-known Member
Joined
Sep 27, 2008
Messages
1,557
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.
 

Forum statistics

Threads
1,171,689
Messages
5,876,917
Members
433,219
Latest member
mahendraalld92

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
Top