PC Review


Reply
Thread Tools Rate Thread

Disable Save/Save As - not working?

 
 
Silena K-K
Guest
Posts: n/a
 
      10th Dec 2007
Hi Gord

I followed your steps and have the following code in VB but now when I use
"ctrl s" or F12 to test that Save/Save As doesn't work it, crashes Excel.
Any
ideas why? Silena

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
ThisWorkbook.Saved = True
ThisWorkbook.Close

End Sub

Private Sub Workbook_BeforeClose(Cancel As Boolean)
ThisWorkbook.Saved = True

End Sub

 
Reply With Quote
 
 
 
 
Jim Rech
Guest
Posts: n/a
 
      10th Dec 2007
In place of this:

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)
ThisWorkbook.Saved = True
ThisWorkbook.Close
End Sub

I think all you need is:

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

Leave the other sub as is. None of this will work if macros are not
enabled, so this is not hard to defeat.

--
Jim
"Silena K-K" <(E-Mail Removed)> wrote in message
news:6798F693-FD20-4C1D-85C4-(E-Mail Removed)...
| Hi Gord
|
| I followed your steps and have the following code in VB but now when I use
| "ctrl s" or F12 to test that Save/Save As doesn't work it, crashes Excel.
| Any
| ideas why? Silena
|
| Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)
| ThisWorkbook.Saved = True
| ThisWorkbook.Close
|
| End Sub
|
| Private Sub Workbook_BeforeClose(Cancel As Boolean)
| ThisWorkbook.Saved = True
|
| End Sub
|


 
Reply With Quote
 
Silena K-K
Guest
Posts: n/a
 
      10th Dec 2007
Thanks Jim for help on the 'save' issue.

I found your reply to disabling the copy command earlier this year ...

Sub DisableCopyCtrl()
Dim Ctrls As CommandBarControls
Dim Ctrl As CommandBarControl
Set Ctrls = CommandBars.FindControls(, 19)
For Each Ctrl In Ctrls
Ctrl.Enabled = False
Next
End Sub

....but haven't been able to get it to work. I pasted it into a general
module and saved it (not sure how to "enable" other than save??)

Can you help with this? Thanks Silena


"Jim Rech" wrote:

> In place of this:
>
> Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
> Boolean)
> ThisWorkbook.Saved = True
> ThisWorkbook.Close
> End Sub
>
> I think all you need is:
>
> Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
> Boolean)
> Cancel = True
> End Sub
>
> Leave the other sub as is. None of this will work if macros are not
> enabled, so this is not hard to defeat.
>
> --
> Jim
> "Silena K-K" <(E-Mail Removed)> wrote in message
> news:6798F693-FD20-4C1D-85C4-(E-Mail Removed)...
> | Hi Gord
> |
> | I followed your steps and have the following code in VB but now when I use
> | "ctrl s" or F12 to test that Save/Save As doesn't work it, crashes Excel.
> | Any
> | ideas why? Silena
> |
> | Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
> Boolean)
> | ThisWorkbook.Saved = True
> | ThisWorkbook.Close
> |
> | End Sub
> |
> | Private Sub Workbook_BeforeClose(Cancel As Boolean)
> | ThisWorkbook.Saved = True
> |
> | End Sub
> |
>
>
>

 
Reply With Quote
 
Jim Rech
Guest
Posts: n/a
 
      11th Dec 2007
Like all code it has to be run to do something<g>.

Since a sub named Auto_Open will execute automatically when Excel opens a
workbook you can cause my sub to be run like this:

Sub Auto_Open()
DisableCopyCtrl
End Sub

This can go in the same standard module. Users can disable macros though.
If they do this code will not run.

--
Jim
"Silena K-K" <(E-Mail Removed)> wrote in message
news:19F43DB6-A094-4E99-924C-(E-Mail Removed)...
| Thanks Jim for help on the 'save' issue.
|
| I found your reply to disabling the copy command earlier this year ...
|
| Sub DisableCopyCtrl()
| Dim Ctrls As CommandBarControls
| Dim Ctrl As CommandBarControl
| Set Ctrls = CommandBars.FindControls(, 19)
| For Each Ctrl In Ctrls
| Ctrl.Enabled = False
| Next
| End Sub
|
| ...but haven't been able to get it to work. I pasted it into a general
| module and saved it (not sure how to "enable" other than save??)
|
| Can you help with this? Thanks Silena
|
|
| "Jim Rech" wrote:
|
| > In place of this:
| >
| > Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
| > Boolean)
| > ThisWorkbook.Saved = True
| > ThisWorkbook.Close
| > End Sub
| >
| > I think all you need is:
| >
| > Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
| > Boolean)
| > Cancel = True
| > End Sub
| >
| > Leave the other sub as is. None of this will work if macros are not
| > enabled, so this is not hard to defeat.
| >
| > --
| > Jim
| > "Silena K-K" <(E-Mail Removed)> wrote in message
| > news:6798F693-FD20-4C1D-85C4-(E-Mail Removed)...
| > | Hi Gord
| > |
| > | I followed your steps and have the following code in VB but now when I
use
| > | "ctrl s" or F12 to test that Save/Save As doesn't work it, crashes
Excel.
| > | Any
| > | ideas why? Silena
| > |
| > | Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
| > Boolean)
| > | ThisWorkbook.Saved = True
| > | ThisWorkbook.Close
| > |
| > | End Sub
| > |
| > | Private Sub Workbook_BeforeClose(Cancel As Boolean)
| > | ThisWorkbook.Saved = True
| > |
| > | End Sub
| > |
| >
| >
| >


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Disable Save, Save As function in emails - Outlook 2003 lesteryeo@gmail.com Microsoft Outlook 5 27th Oct 2007 06:20 PM
Disable save & save as then return message... J.W. Aldridge Microsoft Excel Programming 2 15th Sep 2006 04:35 PM
disable save and saveas from menubar and save via command button =?Utf-8?B?U3RldmUgRQ==?= Microsoft Excel Programming 5 13th Sep 2006 11:51 PM
Disable save, save as, but allow save via command button =?Utf-8?B?VGltTg==?= Microsoft Excel Programming 10 1st Sep 2006 07:05 PM
redirect or disable save button or file>save Microsoft Outlook VBA Programming 6 11th Mar 2004 03:36 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:16 PM.