PDA

View Full Version : Using VBA to disable Save and Save As



IMS1980
02-12-2013, 06:46 AM
Hi,
I have spent the entire morning trying to cut and paste VBA code that I have found online to disable the "Save" and "Save As" funtion in an Excel 2007 - yes, I am a novice!!

Can anyone take pity and write me a step by step process for this??? Or direct me to a previous posting?

Any help greatly appreciated.

Lonewolf
02-12-2013, 08:59 AM
Hello sorry i tried to add a link but it did not let me so here is some codes i used. Following codes should go in ThisWorkbook Sheet

The code below is if you like to have a password to save it.

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, _
Cancel As Boolean)
Dim strA As String
strA = InputBox("Enter password to save this file")
If strA <> "Password" Then Cancel = True
End Sub

The code below is for not to be able to click on save or saveAs.

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, _
Cancel As Boolean)
Cancel = True
End Sub

The code below will allow you to save the codes above.

Private Sub Save
Application.DisplayAlerts = False
Application.EnableEvents = False
ActiveWorkbook.Save
Application.DisplayAlerts = True
Application.EnableEvents = True
end sub

i hope this helps you.