Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default having trouble disabling "save", "save as" (2003)

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.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 141
Default having trouble disabling "save", "save as" (2003)

On Jan 23, 11:08*am, "dman" wrote:
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.


Try re-enableing it before the workbook closes. add the code below:

Private Sub Workbook_BeforeClose(Cancel As Boolean)
ThisWorkbook.Application.CommandBars("Worksheet menu bar").Controls
_
("&file").Controls("&Save").Enabled = True


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

End Sub
  #3   Report Post  
Posted to microsoft.public.excel.programming
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.



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default having trouble disabling "save", "save as" (2003)

Wow. That's much easier! And it works on 'save as' and the X, too.

Thanks!!

"Otto Moehrbach" wrote in message
...
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.





  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default having trouble disabling "save", "save as" (2003)

If you really want to disable all saves, you could try this workbook level
event:

Option Explicit
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Cancel = True
MsgBox "Cannot be saved!"
End Sub

If macros are disabled (or events are disabled), this will fail.

And remember that you have to disable events before you can update the file,
too.

dman wrote:

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.


--

Dave Peterson


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default having trouble disabling "save", "save as" (2003)

How can I close my workbook, or prevent if from opening, if the user
selects disable marcos at startup?

"Dave Peterson" wrote in message
...
If you really want to disable all saves, you could try this workbook level
event:

Option Explicit
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)
Cancel = True
MsgBox "Cannot be saved!"
End Sub

If macros are disabled (or events are disabled), this will fail.

And remember that you have to disable events before you can update the
file,
too.

dman wrote:

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.


--

Dave Peterson



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default having trouble disabling "save", "save as" (2003)

If the user doesn't allow macros to run, then none of your macros will run.

You could password protect the workbook and then provide a helper workbook that
would open that workbook.
If macros are disabled for the helper workbook, then the real workbook won't
open.

If macros are enabled for the helper workbook, then the real workbook will have
macros enabled.



dman wrote:

How can I close my workbook, or prevent if from opening, if the user
selects disable marcos at startup?

"Dave Peterson" wrote in message
...
If you really want to disable all saves, you could try this workbook level
event:

Option Explicit
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)
Cancel = True
MsgBox "Cannot be saved!"
End Sub

If macros are disabled (or events are disabled), this will fail.

And remember that you have to disable events before you can update the
file,
too.

dman wrote:

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.


--

Dave Peterson


--

Dave Peterson
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Selecting "Save As" adds "Copy of" to file name- MS Excel 2007 ronhansen Excel Discussion (Misc queries) 1 November 15th 09 09:33 PM
"CELL("FILENAME") NOT UPDATE AFTER "SAVE AS" ACTION yossie6 Excel Discussion (Misc queries) 1 June 16th 08 12:16 PM
In Excel 2003 is there a way to prevent "Save As" and "Print"? lucky2000 Excel Discussion (Misc queries) 3 April 26th 07 02:49 PM
"Save" and "Save As" options greyed out - "Save as Webpage" option Bill Excel Discussion (Misc queries) 0 January 16th 07 04:47 PM
Disabling "SAVE AS" option under "File" Bidyut Bhattacharjee Excel Discussion (Misc queries) 3 March 22nd 06 06:35 PM


All times are GMT +1. The time now is 09:47 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"