Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Totally Disabling (^ save ) (Save as) and Save Icon – Which code do I use:


I’ve searched as much as I can, to find out which how to disable sav
completely, so effectivly, all ways to save should be disabled. Th
user won’t 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

--
harpscardif
-----------------------------------------------------------------------
harpscardiff's Profile:
http://www.excelforum.com/member.php...fo&userid=2596
View this thread: http://www.excelforum.com/showthread.php?threadid=48344

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


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 45
Default Totally Disabling (^ save ) (Save as) and Save Icon - Which code do I use:

Don't bother. If the user really wants to save the workbook, there's
utlimately nothing you can do to stop them. All of your methods would be
defeated simply by opening the workbook with macros disabled. Or by
switching to VBA and saving the workbook manually. Or by using Customise to
reassign the Save command to any toolbar or menu. Etc.

In practice, it's just as effective to put a note in the workbook: "Please
don't save this workbook."




"harpscardiff"
wrote in message
news:harpscardiff.1y875b_1131533422.7986@excelforu m-nospam.com...

I've 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 won't 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



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Totally Disabling (^ save ) (Save as) and Save Icon – Which code do I use:


Thanks for your response.

I want to disable all kinds of save functionality: The code which you
stated only works with file save as.

Any ideas which code disables all save functionality?

Thanks


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

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Totally Disabling (^ save ) (Save as) and Save Icon – Which code do I use:


The way my document works is on open a form pops up, once the form is
completed it tranposes the data onto the worksheet. So effectivley to
complete the form they must have Macros enabled.

Also if I disabled most of the saved options: Shortcut, File save as
and icon, the users will quit trying. As there knowledge of Excel of
quite slim. With the expections of a few users.

Thanks


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



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 23
Default Totally Disabling (^ save ) (Save as) and Save Icon €“ Which co

The code in my message works whether you click on the save icon in the
toolbar or you use File/Save or File Save As or the save icon in the toolbar
of the VBA editor. At least it does here.

But as Jezebel stated, you have to make sure users aren't able to disable
VBA execution. I don't know if there is an easy way to do that. You could use
policies and certificates, but that is really far fetched :)

"harpscardiff" wrote:


Thanks for your response.

I want to disable all kinds of save functionality: The code which you
stated only works with file save as.

Any ideas which code disables all save functionality?

Thanks


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


  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Totally Disabling (^ save ) (Save as) and Save Icon – Which code do I use:


Herbert - Thanks alot, the code does work.

Now that i've entered the code, how do save the change ready for the
users?


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

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Totally Disabling (^ save ) (Save as) and Save Icon - Which code do I use:

Open the Immediate Window in VBA (Ctrl+G), and enter the
following lines, each followed by ENTER:

Application.EnableEvents = False
ThisWorkbook.Save
Application.EnableEvents = True


Of course, your users could do exactly the same thing to save the
file.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com




"harpscardiff"
wrote
in message
...

Herbert - Thanks alot, the code does work.

Now that i've entered the code, how do save the change ready
for the
users?


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



  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 45
Default Totally Disabling (^ save ) (Save as) and Save Icon - Which code do I use:

They can also open the document with macros disabled and defeat the exercise
entirely.



"Chip Pearson" wrote in message
...
Open the Immediate Window in VBA (Ctrl+G), and enter the following lines,
each followed by ENTER:

Application.EnableEvents = False
ThisWorkbook.Save
Application.EnableEvents = True


Of course, your users could do exactly the same thing to save the file.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com




"harpscardiff"
wrote in message
...

Herbert - Thanks alot, the code does work.

Now that i've entered the code, how do save the change ready for the
users?


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





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
Set Up the Save Icon to "Gray Out" if No Changes since last Save XRacr Excel Discussion (Misc queries) 0 February 1st 07 07:54 PM
how to get disk icon on save button of save as dialog like 2000 RichT Excel Discussion (Misc queries) 2 March 9th 06 08:13 PM
Placing a code before Save & Save As Alex Martinez Excel Programming 1 September 27th 05 06:35 AM
Disabling Save Upon Exit Elena Excel Programming 6 June 7th 05 11:13 AM
Disabling Save Pop-Up R. Woltner Excel Programming 0 July 7th 04 12:28 AM


All times are GMT +1. The time now is 03:11 PM.

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"