The user would like to know if you can open an excel workbook in read only if the computer user and computer name doesn’t match existing criteria. Example: if the main person to open the wb is computer name is WS2019, and the logon name is wsmith, but the computer name opening the wb is RS2019 and the login name is rgraves, then the user need the excel wb to open up in “read only” so the the excel wb cannot be saved and if changes need to be made, only wsmith can open it and make the changes. The user has multi-users that use this excel workbook everyday and if changes need made, only I know how to make them. The user is not always the first to open it up and so if changes needs made, therefore has to get everyone to close the workbook so that the user can open it and make the changes. The user also does not want the possibility that the workbook can be saved by others.
Private Sub Workbook_Open() On Error Resume Next If Environ("USERNAME") <> " enter name here" Then ThisWorkbook.ChangeFileAccess Mode:=xlReadOnly End Sub
Obtained from the OzGrid Help Forum.
Solution provided by royUK.
|How to extract characters|
|How to make all empty textboxes invisible|
Click here to visit our Free 24/7 Excel/VBA Help Forum where there are thousands of posts you can get information from, or you can join the Forum and post your own questions. Help clients and freelancers connect, https://laborx.com/ providing efficient blockchain transactions and robust protections through smart contracts - wherever you're based.