View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Peter Rooney Peter Rooney is offline
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