auto open workbook to make read-only

T

Tim C

I want to manually open a protected workbook and for it to open read-only
with out a dialog box.

If the above requires the use of the auto_open event, how do I turn this off
when I open the protected workbook programmatically?

I'm using excel 2003
 
R

ryguy7272

For an old post:
Option Explicit
Sub auto_open()

Dim resp As Long
If ThisWorkbook.ReadOnly = True Then
'they opened it readonly
'do nothing
Else
resp = MsgBox(Prompt:="What to change it to readonly?", _
Buttons:=vbYesNo)

If resp = vbYes Then
ThisWorkbook.ChangeFileAccess xlReadOnly
End If
End If

End Sub

Hit Alt+F11, double-click 'ThisWorkbook' and paste the code in there.
Finally, File|SaveAs|tools|general options|check that "read-only recommended"
box.

Good luck,
Ryan---
 
T

Tim C

Thanks for the help but this does not suppress the initial dialogue box
asking to read only or not. Also sub auto-open() does not work for me whereas
sub workbook auto_open does? Why is this? The only way I can get around this
is not to have the workbook saved password protected or readonly but make it
readonly automatically on the auto-open using the code:

Private Sub Workbook_Open()
ThisWorkbook.ChangeFileAccess xlReadOnly
End Sub


Cheers, Tim
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top