Read only Spreadsheet, Save As non-Read Only

moogthemoog

Board Regular
Joined
Nov 17, 2004
Messages
51
I have a Spreadsheet that has Read Only Recommended. When a user wants to Save it, I want a new Filename entered by the user, and to make sure that the Read-Only Recommended status is switched off (i.e. Read-Write always On)

Although my users can do this by File-SaveAs, most of them forget to switch the Read only recommended status off in the SaveAs dialog box.

What would be the code for this? My code below falls over on the Workbook.SaveAs line. I'm trying to use xlDialogSaveAs as the filename, but it's failing also!

Code:
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)

Application.EnableEvents = False
Application.Dialogs(xlDialogSaveAs).Show
If Not Me.ReadOnly Then
Workbook.SaveAs Filename:=xlDialogSaveAs, ReadOnlyRecommended:=False
End If
SaveAsUI = False
Cancel = True
Application.EnableEvents = True

End Sub
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
Unfortunately, this still doesn't work.
I've just tried something, and using SaveAs does clear the Read Only by default - but only when the Property of the file is set as Read Only within Windows Explorer.

However, if the file is set to "Read-only recommended" via the checkbox on the Excel SaveAs Dialog box (using Tools/General Options), then the code doesn't work, and it would appear that when manually using SaveAs, the user must remember to untick that checkbox in the General Options.

I was hoping for VBA to force the issue...
 
Upvote 0

Forum statistics

Threads
1,215,327
Messages
6,124,287
Members
449,149
Latest member
mwdbActuary

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