Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Hii All!!!! does anybody knows how can i cancel the save and the save as commands

Hii All!!!! does anybody knows how can i cancel the 'save' and the
'save as' commands fron an excel workbook? does anybody can write a
code to do it, or maybe a different solution...

Thank you,
Alon

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 325
Default Hii All!!!! does anybody knows how can i cancel the save and the s

Hi, Alon,

How about these:

Public Sub SaveOn()

Dim CmdBar1 As CommandBar
Dim CmdBar2 As CommandBar

Set CmdBar1 = Excel.CommandBars("Worksheet Menu
Bar").Controls("File").CommandBar

Status = True

For I = 1 To CmdBar1.Controls.Count
CtrlName = CmdBar1.Controls(I).Caption
If CtrlName = "&Save" Or CtrlName = "Save &As..." Then
CmdBar1.Controls(I).Enabled = Status
End If
Next I

Set CmdBar2 = Excel.CommandBars("Standard")
CmdBar2.Controls("Save").Enabled = Status

End Sub

Public Sub SaveOff()

Dim CmdBar1 As CommandBar
Dim CmdBar2 As CommandBar

Set CmdBar1 = Excel.CommandBars("Worksheet Menu
Bar").Controls("File").CommandBar

Status = False

For I = 1 To CmdBar1.Controls.Count
CtrlName = CmdBar1.Controls(I).Caption
If CtrlName = "&Save" Or CtrlName = "Save &As..." Then
CmdBar1.Controls(I).Enabled = Status
End If
Next I

Set CmdBar2 = Excel.CommandBars("Standard")
CmdBar2.Controls("Save").Enabled = Status

End Sub

You could modify them to and move them to "ThisWorkbook" as event macros
too, I should think.

Regards

Pete

"Alon" wrote:

Hii All!!!! does anybody knows how can i cancel the 'save' and the
'save as' commands fron an excel workbook? does anybody can write a
code to do it, or maybe a different solution...

Thank you,
Alon


  #3   Report Post  
Posted to microsoft.public.excel.programming
JMB JMB is offline
external usenet poster
 
Posts: 2,062
Default Hii All!!!! does anybody knows how can i cancel the save and the s

Another variation:

You could paste this into the Thisworkbook module of your workbook through
the VBA editor

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Cancel = True
End Sub

If you need to suspend this code in order to save the file yourself, you
could write a macro (and put it in a code module of your workbook - or in a
code module of your Personal macro workbook and assign it a button on your
toolbar or a hotkey) to toggle events on/off (the BeforeSave event would be
suspended while events are off-allowing you to save the file):

Sub ToggleEvents()
With Application
.EnableEvents = Not .EnableEvents
If .EnableEvents Then
.StatusBar = False
Else: .StatusBar = "Events Are Off"
End If
End With

End Sub


"Alon" wrote:

Hii All!!!! does anybody knows how can i cancel the 'save' and the
'save as' commands fron an excel workbook? does anybody can write a
code to do it, or maybe a different solution...

Thank you,
Alon


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
save and save as commands not accessible Tina Setting up and Configuration of Excel 1 March 27th 08 01:03 AM
Save - Yes / No / Cancel Jon Peltier Excel Discussion (Misc queries) 9 May 7th 06 02:03 AM
can I cancel a save juls!1601 Excel Discussion (Misc queries) 2 February 16th 06 01:03 AM
Cancel Macro is user selects 'cancel' at save menu Mark Excel Programming 1 April 6th 05 05:45 PM
How to Cancel a Save? Rodg2000 Excel Programming 1 January 9th 04 10:47 AM


All times are GMT +1. The time now is 07:19 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"