Guest User

Untitled

a guest
Sep 2nd, 2018
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. Sub SetAsReadOnly()
  2. ****'** Test for PC User Name
  3. ****Dim strUser As String
  4. ********strUser = Environ("USERNAME")
  5. ********
  6. ******** '**Set Read only File Access for each Office's specific version
  7. ********Select Case strUser
  8. ************'** Full Workbook Access
  9. ************Case Is = "YourUserName", "AnotherUser"
  10. ****************If ActiveWorkbook.ReadOnly Then _
  11. ********************ActiveWorkbook.ChangeFileAccess Mode:=xlReadWrite, WritePassword:="admin"
  12. ************'** Limit Access
  13. ************Case Is <> "YourUserName"
  14. ****************If Not ActiveWorkbook.ReadOnly Then _
  15. ********************ActiveWorkbook.ChangeFileAccess Mode:=xlReadOnly, WritePassword:="admin"
  16. ********End Select
  17.  
  18. End Sub
Add Comment
Please, Sign In to add comment