简体   繁体   中英

Excel VBA Only Allow Administrator to Modify Workbook

I am having some issues with VBA to allow only Administrators 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 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM