View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Otto Moehrbach Otto Moehrbach is offline
external usenet poster
 
Posts: 1,090
Default having trouble disabling "save", "save as" (2003)

Use something like this:
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)
SaveAsUI = False
Cancel = True
End Sub
This macro must be placed in the workbook module. To access that module,
right-click the Excel icon that is immediately to the left of the word
"File" in the menu across the top of your screen, and select View Code.
Paste this macro into that module. "X" out of the module to return to your
sheet.
Note that with this macro in place you will not be able to save the file at
all. That means that you cannot save the file with this macro in place.
You will have to add some code to this macro to make the canceling of the
Save command conditional. Come back if you need help with doing so. HTH
Otto
"dman" wrote in message
...
Hi.

I have a workbook that I do not want the user to be able to save or save
as.
The code I have disables the proper icons, however, when I start Excel up
again
with a different workbook, the icons are still disabled.

If I remove the .application, I get object var or with block var not set.
How do I
disable the save/save as for only the workbook I need? Here is my code int
he the
Workbook_Open sub.

ThisWorkbook.Application.CommandBars("Worksheet menu bar").Controls _
("&file").Controls("&Save").Enabled = False

ThisWorkbook.CommandBars("Worksheet menu bar").Controls _
("&file").Controls("&Save").Enabled = False

Help. Thanks.