IF THEN rule to open as Read Only for other users

Falcon50

New Member
Joined
Oct 27, 2014
Messages
5
Hello at my work we have procedure Word Documents in a share drive that everyone uses for day to day reference. If other users currently have it open and I need to make an update I can't do so until they get out of it. I found online the macro below that solves this problem but in Excel only. I was able to modify it to allow me and other users to have write access and everyone else open the excel sheets in read only mode. Even if the other users have opened it this code allowed me to go in and make necessary changes to the excel sheets.

Private Sub Workbook_Open()
Users = Environ("USERNAME")
Select Case Users
Case "jake": MsgBox "ok"
Case "joseph": MsgBox "ok"
Case "tracy": MsgBox "ok"
Case Else
Application.DisplayAlerts = False
On Error Resume Next
'may already be read only
If ThisWorkbook.Path <> vbNullString Then ThisWorkbook.ChangeFileAccess xlReadOnly
On Error GoTo 0
Application.DisplayAlerts = True
End Select
End Sub

I tried adapting this in the Word ThisDocument Open module but given that I am still a novice with VBA I couldn't get it to work.
Is it possible to modify this macro to work in MS Word? Any help with this is greatly appreciated!
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
It may just be easier to save the file as read-only with a password, then provide said password to the folks that have permission to open the file and edit it.

1) FIle>Save As
2) In the savve as dialog box, next to the Save button, Tools>General Options
3) in the second text box "Password to Modify" type in your password
4) re-type password

Now when the file is opened the user will get a popup asking for a password, or they select read-only
 
Upvote 0

Forum statistics

Threads
1,215,064
Messages
6,122,939
Members
449,094
Latest member
teemeren

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top