Gary Dorman
Gary Dorman

Reputation: 477

Disable Save As In A Batch Of Excel Files

I've been researching how to disable "Save As" in Excel and it seems possible. I have a macro that loops through a bunch of Excel files making changes. In that macro I would like to disable "Save As" for all of the files. Is this possible?

Upvotes: 0

Views: 229

Answers (2)

Dokat
Dokat

Reputation: 21

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

    MsgBox "You can't save this workbook!"
    Cancel = True

End Sub

Upvotes: 0

jsanchezs
jsanchezs

Reputation: 2070

Using application object. You just add this lines to the code that loops in every file or workbook so it disable "save as" for each one :

Application.CommandBars("Worksheet Menu Bar").Controls("File").Controls("Save As...").Enabled = False 
Application.CommandBars("Worksheet Menu Bar").Controls("File").Controls("Save").Enabled = False 

Tell me how it goes.

Upvotes: 1

Related Questions