Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

trying to disable save and save as on workbook

Status
Not open for further replies.

rrmcguire

Programmer
Oct 13, 2010
304
US
Hello I have the below code which I've put in the Visual Basic editor in excel:

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
MsgBox "The 'Save and Save As' function has been disabled."
Cancel = True
End Sub

And it does what I want it to to prevent the user from using save or save as but when in the editor after I've put the code in how do I save it so that its saved to the workbook if this is disabled? Also how would you prevent using ctrl-S as well?

thanks for any help provided
 


Hi,

Goes thru the same event.

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 



I see you had TWO questions.

How do YOU save it?

You must first save your workbook containing any macros WITHOUT THE CODE ABOVE.

Then OPEN with macros disabled.

Add your save prevention code.

SAVE.

Open and enable macros.

Now you will not be able to save using any method.

However, you see that there is a back door -- Open with macros disabled. You may want to code to defeat that eventuality.

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Alternatively, in VBE or Visual Basic excel toolbar, turn the design mode on, save workbook, turn off design mode.

combo
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top