Opened ReadOnly Flag in VBA?

Matanuska

New Member
Joined
Feb 21, 2002
Messages
34
I've got an Excel workbook that I've saved with the password required to modify file sharing option (under Save As / Options).

For some reason I haven't been able to figure out yet, simply opening the workbook read only & immediately closing it without making any changes sets the dirty bit & the user is prompted to save changes on close.

Until I can figure out what's setting the dirty bit, I'd like to test the Saved property in a Workbook_Close routine and allow the user to close without saving, but only if the workbook was opened read only.

Is this possible? If so, what property can I test to see if the workbook was opened read-only?
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
Quite easy this:-

Code:
Sub Test()
If ThisWorkbook.ReadOnly = True Then
    MsgBox "This is Readonly"
Else
    MsgBox "This is a read/write workbook"
End If
End Sub

HTH,

D
 
Upvote 0

Forum statistics

Threads
1,213,496
Messages
6,113,993
Members
448,539
Latest member
alex78

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