开发者

Excel VBA Only Allow Administrator to Modify Workbook

开发者 https://www.devze.com 2023-01-27 03:35 出处:网络
I am having some issues with VBA to allow only Administrato开发者_JAVA技巧rs to modify an excel workbook. Can anyone help me with the code to make this happen? Thanks!Getting the username is fairly st

I am having some issues with VBA to allow only Administrato开发者_JAVA技巧rs to modify an excel workbook. Can anyone help me with the code to make this happen? Thanks!


Getting the username is fairly straightfoward:

 username = Environ("UserName")

It is also possible through API calls, which is detailed here

You can then check that username against your list of administrators. If they are in the list, you can then unprotect the workbook.

 ThisWorkbook.Unprotect 
0

精彩评论

暂无评论...
验证码 换一张
取 消