OzGrid

How to read only open an excel workbook (multiple users simultaneously)

< Back to Search results

 Category: [Excel]  Demo Available 

How to read only open an excel workbook (multiple users simultaneously)

 

Requirement:

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.

 

Solution:

Code:

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.

 

See also: Index to Excel VBA Code and Index to Excel Freebies and Lesson 1 - Excel Fundamentals and Index to how to… providing a range of solutions and Index to new resources and reference sheets

 

See also:

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.


Gallery



stars (0 Reviews)