Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
PG PG is offline
external usenet poster
 
Posts: 11
Default Disable "save" option on close.

I would like to disable the "Do you want to save changes..." message after
running a macro when exiting the Excel program. I have a macro that runs and
changes the cell in a varies sheets, but I do not want my end user to be able
to save the changes. I have setup formulas thought out the sheets and I do
not want to load them every time. When I exit out of the program it promotes
me to always save. Is there a way to disable this or maybe make my Msgbox
button just exit out of the program without saving changes when click on
€œOK€? Then on that note, when I want to make changes, will I still be able to
save my workbook and if so, how?
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Disable "save" option on close.

You could put this kind of code in the ThisWorkbook module:

Option Explicit
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Cancel = True
MsgBox "You can't save this!"
End Sub

But when you want to save, you'll have to turn off events.

hit alt-f11 to get to the VBE
hit ctrl-g to see the immediate window
type this and hit enter
application.enableevents = false

then save your workbook.

And remember to togglet that setting back to True
application.enableevents = true

So that events are enabled again.

PG wrote:

I would like to disable the "Do you want to save changes..." message after
running a macro when exiting the Excel program. I have a macro that runs and
changes the cell in a varies sheets, but I do not want my end user to be able
to save the changes. I have setup formulas thought out the sheets and I do
not want to load them every time. When I exit out of the program it promotes
me to always save. Is there a way to disable this or maybe make my Msgbox
button just exit out of the program without saving changes when click on
€œOK€? Then on that note, when I want to make changes, will I still be able to
save my workbook and if so, how?


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Disable "save" option on close.

This shouldn't be in the _BeforeClose event.

It should be in the _BeforeSave event.

Option Explicit
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Cancel = True
MsgBox "You can't save this!"
End Sub

Sorry about the typo.

Dave Peterson wrote:

You could put this kind of code in the ThisWorkbook module:

Option Explicit
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Cancel = True
MsgBox "You can't save this!"
End Sub

But when you want to save, you'll have to turn off events.

hit alt-f11 to get to the VBE
hit ctrl-g to see the immediate window
type this and hit enter
application.enableevents = false

then save your workbook.

And remember to togglet that setting back to True
application.enableevents = true

So that events are enabled again.

PG wrote:

I would like to disable the "Do you want to save changes..." message after
running a macro when exiting the Excel program. I have a macro that runs and
changes the cell in a varies sheets, but I do not want my end user to be able
to save the changes. I have setup formulas thought out the sheets and I do
not want to load them every time. When I exit out of the program it promotes
me to always save. Is there a way to disable this or maybe make my Msgbox
button just exit out of the program without saving changes when click on
€œOK€? Then on that note, when I want to make changes, will I still be able to
save my workbook and if so, how?


--

Dave Peterson


--

Dave Peterson
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
Why excel close all files when I just want to close one files hon123456 Excel Discussion (Misc queries) 2 December 8th 10 12:12 PM
close workbook without closing excel and stop recursive function chris Excel Discussion (Misc queries) 3 July 10th 06 08:23 PM
Disable Tools Protection Protect Sheet for all users but one Win XP Excel Discussion (Misc queries) 6 January 17th 06 10:46 PM
Excel shoud not close all active books when clicking close button technomike Excel Discussion (Misc queries) 0 June 10th 05 05:35 PM
Disable "Save As" Option Andy T Excel Discussion (Misc queries) 1 December 10th 04 10:23 AM


All times are GMT +1. The time now is 09:27 AM.

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"