PDA

View Full Version : open as read only no save prompt



wilg
08-14-2011, 07:37 PM
Hi I want to be able to check the username of the person opening on of my work books. I use the environ("username") to check this.

If the user is not someone I want to edit the workbook I want the workbook to open as a read only and not prompt for save or have ability to save.

Any suggestions..Thanks in advance.

mancubus
08-15-2011, 01:57 AM
hi.
see if this helps.


Private Sub Workbook_Open()
'http://forums.techarena.in/software-development/1176886.htm

Application.DisplayAlerts = False
If Environ("Username") = "Administrator" or Environ("Username") = "XYZ" then
MsgBox "It's in Edit mode"
Workbooks.Open "d:\Example.xls"
Else
MsgBox "It's in Read Only mode"
Workbooks.Open "d:\Example.xls", , True
End If
Application.DisplayAlerts = True
End Sub