View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Steve E Steve E is offline
external usenet poster
 
Posts: 62
Default disable save and saveas from menubar and save via command button

OK... truly stupid situation:

My Excel2003 workbook project has the save and saveas menu commands disabled
via this code in the ThisWorkbook module:

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As _
Boolean)
'Removes the save button from the toolbar and removes save from file menu
'User should only save by using save command button

Dim MySave As Boolean
Dim wb As Workbook
Set wb = ActiveWorkbook
If Not MySave Then Cancel = True
MySave = False
End Sub

In my worksheet I have a button that when clicked runs a routine to make
sure that all of the info is entered and is error trapped, saves a copy of
the workbook and emails it to a database application that records the data.
Works like a champ thanks to the help of Ron DeBruin's site...

Unfortunately, I don't have a way of saving a "blank" workbook to use as the
master file... (blank meaning without the user inputs)... so I thought I'd
try and set another button well out of the visible display area and assign a
similar bit of code to save the workbook (not a copy) while I'm working on it
and before the user inputs their data...

so I have this in the same worksheet as the other event code but this
doesn't seem to do anything at all... obviously I'm missing something simple
but am just too dense to see what it might be.


Public MySave As Boolean 'at top of worksheet module before any other code

Public Sub SaveWorkbook() 'assigned to form button on worksheet
Dim wb As Workbook
Dim Cancel As Boolean

Set wb = ActiveWorkbook

MySave = True
wb.SaveAs "filename"
If Not MySave Then
Cancel = True
Else
MySave = False
End If


End Sub

Help?

TIA,

Steve