View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Herbert Herbert is offline
external usenet poster
 
Posts: 23
Default Totally Disabling (^ save ) (Save as) and Save Icon €“ Which code d

Hello!

Do you want to suppress 'save as' only, or saving in general?

To disable all kind of save-functionality this should work:

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Msgbox "Saving has been disabled.", vbInformation
Cancel = True
End Sub

Regards,
Herbert

"harpscardiff" wrote:


Ive searched as much as I can, to find out which how to disable save
completely, so effectivly, all ways to save should be disabled. The
user wont need to save the document.

This is what I have found:

1.

Code:
--------------------


Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
If SaveAsUI Then
Msgbox "The 'Save As' function has been disabled.", vbInformation, "Save As Disabled"
Cancel = True
End If
End Sub

--------------------


2.


Code:
--------------------

Private Sub Workbook_BeforeClose(Cancel As Boolean)
ActiveWorkbook.Close SaveChanges:=False
End Sub

--------------------


3.

Code:
--------------------

Private Sub StopSave()
' Trap and call the OurSaveProcedure() macro when Control-S is pressed
If Application.OnKey("^s", "") Then ' Prefix ^ (caret) for Ctrl key
Msgbox "Save has been disabled"
End If
End Sub

--------------------


4.

Code:
--------------------

Public Sub MenuSave(Enable As Boolean)

'////////////////////////////////////////////////////////'
'/ /'
'/ - Worksheet Menu and Standard Menu - /'
'/ Enable or Disable Save Menu Option /'
'/ /'
'////////////////////////////////////////////////////////'

'Written April 25, 2005
'Author: Leith Ross
'E-mail:

Dim Status
Dim CmdBar1 As CommandBar
Dim CmdBar2 As CommandBar

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

Status = Enable

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

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

End Sub

--------------------


Which is the best to use?

Apprecaite your time.


--
harpscardiff
------------------------------------------------------------------------
harpscardiff's Profile:
http://www.excelforum.com/member.php...o&userid=25960
View this thread: http://www.excelforum.com/showthread...hreadid=483443