PC Review


Reply
Thread Tools Rate Thread

Disable 'save' command in Excel 2000

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

I have created a worksheet form in Excel which will be used as a template
and want to be able to disable the save command.

The idea is that the users enter their data, print out the results and then
close the form without it saving. We want the form to automatically close
without saving, not ask the user whether they want to save or not.

Is there a macro command and/or code that can do that??

Thanks and Merry Christmas. Silena
 
Reply With Quote
 
 
 
 
Gord Dibben
Guest
Posts: n/a
 
      9th Dec 2007
Entered into Thisworkbook module to cover user hitting the Save Icon or
File>Save.

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

Workbook will close with no save taking place because you have faked it out with
"I'm already saved".

You may want to also put code into the BeforeClose event.to cover them just
closing. Workbook will close with no save or alert.

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


Gord Dibben MS Excel MVP

On Sun, 9 Dec 2007 13:52:01 -0800, Silena K-K
<(E-Mail Removed)> wrote:

>Hi
>
>I have created a worksheet form in Excel which will be used as a template
>and want to be able to disable the save command.
>
>The idea is that the users enter their data, print out the results and then
>close the form without it saving. We want the form to automatically close
>without saving, not ask the user whether they want to save or not.
>
>Is there a macro command and/or code that can do that??
>
>Thanks and Merry Christmas. Silena


 
Reply With Quote
 
Silena K-K
Guest
Posts: n/a
 
      9th Dec 2007
Hi Gord

I have tried this and it doesn't seem to work - although it's highly likely
that I'm not writing it into VB correctly.

I copied the text below from "Private Sub" to "End Sub" and pasted it into
VB by selecting Tools, Macros, VB Editor and then double clicking on the
"This workbook" module and pasting the code into the blank screen.

Is that correct??

Silena


"Gord Dibben" wrote:

> Entered into Thisworkbook module to cover user hitting the Save Icon or
> File>Save.
>
> Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
> ThisWorkbook.Saved = True
> ThisWorkbook.Close
> End Sub
>
> Workbook will close with no save taking place because you have faked it out with
> "I'm already saved".
>
> You may want to also put code into the BeforeClose event.to cover them just
> closing. Workbook will close with no save or alert.
>
> Private Sub Workbook_BeforeClose(Cancel As Boolean)
> ThisWorkbook.Saved = True
> End Sub
>
>
> Gord Dibben MS Excel MVP
>
> On Sun, 9 Dec 2007 13:52:01 -0800, Silena K-K
> <(E-Mail Removed)> wrote:
>
> >Hi
> >
> >I have created a worksheet form in Excel which will be used as a template
> >and want to be able to disable the save command.
> >
> >The idea is that the users enter their data, print out the results and then
> >close the form without it saving. We want the form to automatically close
> >without saving, not ask the user whether they want to save or not.
> >
> >Is there a macro command and/or code that can do that??
> >
> >Thanks and Merry Christmas. Silena

>
>

 
Reply With Quote
 
Gord Dibben
Guest
Posts: n/a
 
      9th Dec 2007
Yes, that is the proper module to have it in.

But first time you save or close, the workbook will close without saving the
code. My mistake in not explaining this.

Steps to take................

Open the workbook.

Paste the code into Thisworkbook module.

View>Immediate Window.

Type in Application.EnableEvents = False then ENTER key

File>Save the workbook. You will be asked if you want to save changes.

Yes, you do.

Back to the Immediate Window and Application.EnableEvents = True.

Your code when closing or saving the workbook should now work properly.


Gord

On Sun, 9 Dec 2007 15:18:00 -0800, Silena K-K
<(E-Mail Removed)> wrote:

>Hi Gord
>
>I have tried this and it doesn't seem to work - although it's highly likely
>that I'm not writing it into VB correctly.
>
>I copied the text below from "Private Sub" to "End Sub" and pasted it into
>VB by selecting Tools, Macros, VB Editor and then double clicking on the
>"This workbook" module and pasting the code into the blank screen.
>
>Is that correct??
>
>Silena
>
>
>"Gord Dibben" wrote:
>
>> Entered into Thisworkbook module to cover user hitting the Save Icon or
>> File>Save.
>>
>> Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
>> ThisWorkbook.Saved = True
>> ThisWorkbook.Close
>> End Sub
>>
>> Workbook will close with no save taking place because you have faked it out with
>> "I'm already saved".
>>
>> You may want to also put code into the BeforeClose event.to cover them just
>> closing. Workbook will close with no save or alert.
>>
>> Private Sub Workbook_BeforeClose(Cancel As Boolean)
>> ThisWorkbook.Saved = True
>> End Sub
>>
>>
>> Gord Dibben MS Excel MVP
>>
>> On Sun, 9 Dec 2007 13:52:01 -0800, Silena K-K
>> <(E-Mail Removed)> wrote:
>>
>> >Hi
>> >
>> >I have created a worksheet form in Excel which will be used as a template
>> >and want to be able to disable the save command.
>> >
>> >The idea is that the users enter their data, print out the results and then
>> >close the form without it saving. We want the form to automatically close
>> >without saving, not ask the user whether they want to save or not.
>> >
>> >Is there a macro command and/or code that can do that??
>> >
>> >Thanks and Merry Christmas. Silena

>>
>>


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

Still doesn't work.

At the step "File>Save the workbook" I don't get ask if I want to save
changes and the "Application.EnableEvents" does not change from False to True.

Silena

"Gord Dibben" wrote:

> Yes, that is the proper module to have it in.
>
> But first time you save or close, the workbook will close without saving the
> code. My mistake in not explaining this.
>
> Steps to take................
>
> Open the workbook.
>
> Paste the code into Thisworkbook module.
>
> View>Immediate Window.
>
> Type in Application.EnableEvents = False then ENTER key
>
> File>Save the workbook. You will be asked if you want to save changes.
>
> Yes, you do.
>
> Back to the Immediate Window and Application.EnableEvents = True.
>
> Your code when closing or saving the workbook should now work properly.
>
>
> Gord
>
> On Sun, 9 Dec 2007 15:18:00 -0800, Silena K-K
> <(E-Mail Removed)> wrote:
>
> >Hi Gord
> >
> >I have tried this and it doesn't seem to work - although it's highly likely
> >that I'm not writing it into VB correctly.
> >
> >I copied the text below from "Private Sub" to "End Sub" and pasted it into
> >VB by selecting Tools, Macros, VB Editor and then double clicking on the
> >"This workbook" module and pasting the code into the blank screen.
> >
> >Is that correct??
> >
> >Silena
> >
> >
> >"Gord Dibben" wrote:
> >
> >> Entered into Thisworkbook module to cover user hitting the Save Icon or
> >> File>Save.
> >>
> >> Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
> >> ThisWorkbook.Saved = True
> >> ThisWorkbook.Close
> >> End Sub
> >>
> >> Workbook will close with no save taking place because you have faked it out with
> >> "I'm already saved".
> >>
> >> You may want to also put code into the BeforeClose event.to cover them just
> >> closing. Workbook will close with no save or alert.
> >>
> >> Private Sub Workbook_BeforeClose(Cancel As Boolean)
> >> ThisWorkbook.Saved = True
> >> End Sub
> >>
> >>
> >> Gord Dibben MS Excel MVP
> >>
> >> On Sun, 9 Dec 2007 13:52:01 -0800, Silena K-K
> >> <(E-Mail Removed)> wrote:
> >>
> >> >Hi
> >> >
> >> >I have created a worksheet form in Excel which will be used as a template
> >> >and want to be able to disable the save command.
> >> >
> >> >The idea is that the users enter their data, print out the results and then
> >> >close the form without it saving. We want the form to automatically close
> >> >without saving, not ask the user whether they want to save or not.
> >> >
> >> >Is there a macro command and/or code that can do that??
> >> >
> >> >Thanks and Merry Christmas. Silena
> >>
> >>

>
>

 
Reply With Quote
 
Gord Dibben
Guest
Posts: n/a
 
      10th Dec 2007
You have to manually change Application.EnableEvents to True

I'm off now for horses hooves and libations so won't get back untill tomorrow.


Gord


On Sun, 9 Dec 2007 16:24:00 -0800, Silena K-K
<(E-Mail Removed)> wrote:

>Hi Gord
>
>Still doesn't work.
>
>At the step "File>Save the workbook" I don't get ask if I want to save
>changes and the "Application.EnableEvents" does not change from False to True.
>
>Silena
>
>"Gord Dibben" wrote:
>
>> Yes, that is the proper module to have it in.
>>
>> But first time you save or close, the workbook will close without saving the
>> code. My mistake in not explaining this.
>>
>> Steps to take................
>>
>> Open the workbook.
>>
>> Paste the code into Thisworkbook module.
>>
>> View>Immediate Window.
>>
>> Type in Application.EnableEvents = False then ENTER key
>>
>> File>Save the workbook. You will be asked if you want to save changes.
>>
>> Yes, you do.
>>
>> Back to the Immediate Window and Application.EnableEvents = True.
>>
>> Your code when closing or saving the workbook should now work properly.
>>
>>
>> Gord
>>
>> On Sun, 9 Dec 2007 15:18:00 -0800, Silena K-K
>> <(E-Mail Removed)> wrote:
>>
>> >Hi Gord
>> >
>> >I have tried this and it doesn't seem to work - although it's highly likely
>> >that I'm not writing it into VB correctly.
>> >
>> >I copied the text below from "Private Sub" to "End Sub" and pasted it into
>> >VB by selecting Tools, Macros, VB Editor and then double clicking on the
>> >"This workbook" module and pasting the code into the blank screen.
>> >
>> >Is that correct??
>> >
>> >Silena
>> >
>> >
>> >"Gord Dibben" wrote:
>> >
>> >> Entered into Thisworkbook module to cover user hitting the Save Icon or
>> >> File>Save.
>> >>
>> >> Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
>> >> ThisWorkbook.Saved = True
>> >> ThisWorkbook.Close
>> >> End Sub
>> >>
>> >> Workbook will close with no save taking place because you have faked it out with
>> >> "I'm already saved".
>> >>
>> >> You may want to also put code into the BeforeClose event.to cover them just
>> >> closing. Workbook will close with no save or alert.
>> >>
>> >> Private Sub Workbook_BeforeClose(Cancel As Boolean)
>> >> ThisWorkbook.Saved = True
>> >> End Sub
>> >>
>> >>
>> >> Gord Dibben MS Excel MVP
>> >>
>> >> On Sun, 9 Dec 2007 13:52:01 -0800, Silena K-K
>> >> <(E-Mail Removed)> wrote:
>> >>
>> >> >Hi
>> >> >
>> >> >I have created a worksheet form in Excel which will be used as a template
>> >> >and want to be able to disable the save command.
>> >> >
>> >> >The idea is that the users enter their data, print out the results and then
>> >> >close the form without it saving. We want the form to automatically close
>> >> >without saving, not ask the user whether they want to save or not.
>> >> >
>> >> >Is there a macro command and/or code that can do that??
>> >> >
>> >> >Thanks and Merry Christmas. Silena
>> >>
>> >>

>>
>>


 
Reply With Quote
 
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 the save 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



"Gord Dibben" wrote:

> You have to manually change Application.EnableEvents to True
>
> I'm off now for horses hooves and libations so won't get back untill tomorrow.
>
>
> Gord
>
>
> On Sun, 9 Dec 2007 16:24:00 -0800, Silena K-K
> <(E-Mail Removed)> wrote:
>
> >Hi Gord
> >
> >Still doesn't work.
> >
> >At the step "File>Save the workbook" I don't get ask if I want to save
> >changes and the "Application.EnableEvents" does not change from False to True.
> >
> >Silena
> >
> >"Gord Dibben" wrote:
> >
> >> Yes, that is the proper module to have it in.
> >>
> >> But first time you save or close, the workbook will close without saving the
> >> code. My mistake in not explaining this.
> >>
> >> Steps to take................
> >>
> >> Open the workbook.
> >>
> >> Paste the code into Thisworkbook module.
> >>
> >> View>Immediate Window.
> >>
> >> Type in Application.EnableEvents = False then ENTER key
> >>
> >> File>Save the workbook. You will be asked if you want to save changes.
> >>
> >> Yes, you do.
> >>
> >> Back to the Immediate Window and Application.EnableEvents = True.
> >>
> >> Your code when closing or saving the workbook should now work properly.
> >>
> >>
> >> Gord
> >>
> >> On Sun, 9 Dec 2007 15:18:00 -0800, Silena K-K
> >> <(E-Mail Removed)> wrote:
> >>
> >> >Hi Gord
> >> >
> >> >I have tried this and it doesn't seem to work - although it's highly likely
> >> >that I'm not writing it into VB correctly.
> >> >
> >> >I copied the text below from "Private Sub" to "End Sub" and pasted it into
> >> >VB by selecting Tools, Macros, VB Editor and then double clicking on the
> >> >"This workbook" module and pasting the code into the blank screen.
> >> >
> >> >Is that correct??
> >> >
> >> >Silena
> >> >
> >> >
> >> >"Gord Dibben" wrote:
> >> >
> >> >> Entered into Thisworkbook module to cover user hitting the Save Icon or
> >> >> File>Save.
> >> >>
> >> >> Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
> >> >> ThisWorkbook.Saved = True
> >> >> ThisWorkbook.Close
> >> >> End Sub
> >> >>
> >> >> Workbook will close with no save taking place because you have faked it out with
> >> >> "I'm already saved".
> >> >>
> >> >> You may want to also put code into the BeforeClose event.to cover them just
> >> >> closing. Workbook will close with no save or alert.
> >> >>
> >> >> Private Sub Workbook_BeforeClose(Cancel As Boolean)
> >> >> ThisWorkbook.Saved = True
> >> >> End Sub
> >> >>
> >> >>
> >> >> Gord Dibben MS Excel MVP
> >> >>
> >> >> On Sun, 9 Dec 2007 13:52:01 -0800, Silena K-K
> >> >> <(E-Mail Removed)> wrote:
> >> >>
> >> >> >Hi
> >> >> >
> >> >> >I have created a worksheet form in Excel which will be used as a template
> >> >> >and want to be able to disable the save command.
> >> >> >
> >> >> >The idea is that the users enter their data, print out the results and then
> >> >> >close the form without it saving. We want the form to automatically close
> >> >> >without saving, not ask the user whether they want to save or not.
> >> >> >
> >> >> >Is there a macro command and/or code that can do that??
> >> >> >
> >> >> >Thanks and Merry Christmas. Silena
> >> >>
> >> >>
> >>
> >>

>
>

 
Reply With Quote
 
Gord Dibben
Guest
Posts: n/a
 
      10th Dec 2007
I cannot replicate your crashing problem with CTRL + s and F12

Did you reenable events after saving the workbook with the code?

I would presume so.

What happens with File>Save?

What happens when you click on the "Save" Icon on Toolbar?

What happens when you just Close the workbook?

If you want to send me the workbook to me via email I can have a look.

Change the AT and DOT to appropriate punctuation in my posting address.


Gord


On Mon, 10 Dec 2007 12:21:16 -0800, Silena K-K
<(E-Mail Removed)> wrote:

>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 the save 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
>
>
>
>"Gord Dibben" wrote:
>
>> You have to manually change Application.EnableEvents to True
>>
>> I'm off now for horses hooves and libations so won't get back untill tomorrow.
>>
>>
>> Gord
>>
>>
>> On Sun, 9 Dec 2007 16:24:00 -0800, Silena K-K
>> <(E-Mail Removed)> wrote:
>>
>> >Hi Gord
>> >
>> >Still doesn't work.
>> >
>> >At the step "File>Save the workbook" I don't get ask if I want to save
>> >changes and the "Application.EnableEvents" does not change from False to True.
>> >
>> >Silena
>> >
>> >"Gord Dibben" wrote:
>> >
>> >> Yes, that is the proper module to have it in.
>> >>
>> >> But first time you save or close, the workbook will close without saving the
>> >> code. My mistake in not explaining this.
>> >>
>> >> Steps to take................
>> >>
>> >> Open the workbook.
>> >>
>> >> Paste the code into Thisworkbook module.
>> >>
>> >> View>Immediate Window.
>> >>
>> >> Type in Application.EnableEvents = False then ENTER key
>> >>
>> >> File>Save the workbook. You will be asked if you want to save changes.
>> >>
>> >> Yes, you do.
>> >>
>> >> Back to the Immediate Window and Application.EnableEvents = True.
>> >>
>> >> Your code when closing or saving the workbook should now work properly.
>> >>
>> >>
>> >> Gord
>> >>
>> >> On Sun, 9 Dec 2007 15:18:00 -0800, Silena K-K
>> >> <(E-Mail Removed)> wrote:
>> >>
>> >> >Hi Gord
>> >> >
>> >> >I have tried this and it doesn't seem to work - although it's highly likely
>> >> >that I'm not writing it into VB correctly.
>> >> >
>> >> >I copied the text below from "Private Sub" to "End Sub" and pasted it into
>> >> >VB by selecting Tools, Macros, VB Editor and then double clicking on the
>> >> >"This workbook" module and pasting the code into the blank screen.
>> >> >
>> >> >Is that correct??
>> >> >
>> >> >Silena
>> >> >
>> >> >
>> >> >"Gord Dibben" wrote:
>> >> >
>> >> >> Entered into Thisworkbook module to cover user hitting the Save Icon or
>> >> >> File>Save.
>> >> >>
>> >> >> Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
>> >> >> ThisWorkbook.Saved = True
>> >> >> ThisWorkbook.Close
>> >> >> End Sub
>> >> >>
>> >> >> Workbook will close with no save taking place because you have faked it out with
>> >> >> "I'm already saved".
>> >> >>
>> >> >> You may want to also put code into the BeforeClose event.to cover them just
>> >> >> closing. Workbook will close with no save or alert.
>> >> >>
>> >> >> Private Sub Workbook_BeforeClose(Cancel As Boolean)
>> >> >> ThisWorkbook.Saved = True
>> >> >> End Sub
>> >> >>
>> >> >>
>> >> >> Gord Dibben MS Excel MVP
>> >> >>
>> >> >> On Sun, 9 Dec 2007 13:52:01 -0800, Silena K-K
>> >> >> <(E-Mail Removed)> wrote:
>> >> >>
>> >> >> >Hi
>> >> >> >
>> >> >> >I have created a worksheet form in Excel which will be used as a template
>> >> >> >and want to be able to disable the save command.
>> >> >> >
>> >> >> >The idea is that the users enter their data, print out the results and then
>> >> >> >close the form without it saving. We want the form to automatically close
>> >> >> >without saving, not ask the user whether they want to save or not.
>> >> >> >
>> >> >> >Is there a macro command and/or code that can do that??
>> >> >> >
>> >> >> >Thanks and Merry Christmas. Silena
>> >> >>
>> >> >>
>> >>
>> >>

>>
>>


 
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
Can I disable the Save command for an Excel file? =?Utf-8?B?RnJhbGk=?= Microsoft Excel Misc 1 14th Sep 2007 08:43 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
Disable Save under Excel 2000 =?Utf-8?B?QmVu?= Microsoft Excel Programming 7 28th Nov 2005 07:26 PM
disable copy/save as command David Microsoft Excel Worksheet Functions 1 13th Sep 2004 02:35 PM


Features
 

Advertising
 

Newsgroups
 


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