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!
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!