Disable save, save as, but allow save via command button
Oops you also need to set the Boolean back to false after you save.
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)
Dim wb As Workbook
Set wb = ActiveWorkbook
If Not MySave Then Cancel = True
MySave = False
End Sub
Charles
Die_Another_Day wrote:
Create a global variable, then set it to true when you use your command
button Like this:
Dim MySave as Boolean
Sub MySaveMacro()
MySave = True
ActiveWorkbook.SaveAs BlahBlahBlah
End Sub
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)
Dim wb As Workbook
Set wb = ActiveWorkbook
If Not MySave Then Cancel = True
End Sub
HTH
Charles Chickering
TimN wrote:
All,
I have been searching through the archives, but can't locate an answer for
this.
I have a command button that when clicked saves the file as the name in cell
B1.
I also want to disable the Save, Save As and save button on the toolbar. To
accomplish that I located the code below. However when I insert that code,
my command button is also disabled. How can I disable the Save, Save As and
save button on the toolbar but still allow my Save button (command button) to
work?
Please help. Thanks
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Dim wb As Workbook
Set wb = ActiveWorkbook
Cancel = True
End Sub
|