Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
save and save as commands not accessible | Setting up and Configuration of Excel | |||
Save - Yes / No / Cancel | Excel Discussion (Misc queries) | |||
can I cancel a save | Excel Discussion (Misc queries) | |||
Cancel Macro is user selects 'cancel' at save menu | Excel Programming | |||
How to Cancel a Save? | Excel Programming |