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
精彩评论