PC Review


Reply
Thread Tools Rate Thread

How can just opening & closing a workbook prompt the Save? dialog?

 
 
baobob@my-deja.com
Guest
Posts: n/a
 
      26th May 2008
I have an Excel 2002 autoexec workbook which starts automatically when
Excel launches, sets some defaults, then closes its own workbook
again.

It neither reads nor writes to the worksheet, or does anything else to
change the workbook in any way that would prompt the "Save your
changes?" dialog on exit. It just sets some Tools / Options defaults
and exits. It's run for years without incident.

But recently I tweaked it and somehow got it into a state in which the
Save dialog was appearing on close.

To debug it, I moved it out of \XLSTART so that I could load it
manually. I commented the code down so that ALL THE MACRO DID was
close its own workbook without doing anything else. The Save dialog
STILL appeared.

So, after a couple of days of pulling my hair out, I threw in the
towel and saved the workbook as it requested, and the dialog no longer
appears.

Anyone have a notion of what was happening?

Thanks.

***
 
Reply With Quote
 
 
 
 
baobob@my-deja.com
Guest
Posts: n/a
 
      26th May 2008
P.S. I spoke too soon. The dialog has come back, and it still appears
every time I run the macro, even running it manually, and even
executing nothing except simply closing again.

Thanks.

***
 
Reply With Quote
 
baobob@my-deja.com
Guest
Posts: n/a
 
      26th May 2008
P.P.S. I think I spoke even too sooner.

I don't think it has to do with the macro at all.

The macro is Sub Auto_Open, so it executes automatically on load.

I changed its name and don't run the macro at all any more.

On loading the workbook then File / Close, I get the Save dialog. So
is there something in the sheet itself that somehow dynamically
changes upon loading?

Answer: There may be. There is a formula in cell A1. I gotta debug it.

Guess y'all can ignore this thread 'til I find out how the hell I'm
shooting myself in the foot.

***
 
Reply With Quote
 
baobob@my-deja.com
Guest
Posts: n/a
 
      26th May 2008
Aaagggghh!

My fault. I commented out my formula and that stopped the Save dialog.

So it's programmer recreational drug use--again.

***

But do I have a suspicion that Excel 2002 flags the Save condition
differently than previous versions? Because I think I've used that
formula for some years without incident.

***
 
Reply With Quote
 
Per Jessen
Guest
Posts: n/a
 
      26th May 2008
On 26 Maj, 21:25, bao...@my-deja.com wrote:
> P.P.S. I think I spoke even too sooner.
>
> I don't think it has to do with the macro at all.
>
> The macro is Sub Auto_Open, so it executes automatically on load.
>
> I changed its name and don't run the macro at all any more.
>
> On loading the workbook then File / Close, I get the Save dialog. So
> is there something in the sheet itself that somehow dynamically
> changes upon loading?
>
> Answer: There may be. There is a formula in cell A1. I gotta debug it.
>
> Guess y'all can ignore this thread 'til I find out how the hell I'm
> shooting myself in the foot.
>
> ***


Hi

If the value in the formula in A1 changes, then excel will always
prompt to save the workbook.

To avoid this, you can use a workbook_beforeClose event like below:

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

Regards,
Per
 
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
Get Save Prompt when closing workbook immediately after savingworkbook dbKemp Microsoft Excel Programming 2 18th Jan 2008 09:11 PM
How to suppress "Do you want to save" dialog when closing a workbook in a Macro? CW Microsoft Excel Discussion 3 15th Jun 2007 04:02 PM
no updates prompt at opening and save changes at closing =?Utf-8?B?U2hhcmlx?= Microsoft Excel Misc 2 9th Jan 2007 01:19 AM
No save prompt when closing workbook =?Utf-8?B?YnVkZnJvZzEzMA==?= Microsoft Excel Misc 0 6th Dec 2005 01:54 PM
Re: Save prompt when closing an unchanged workbook Ron de Bruin Microsoft Excel Misc 0 21st Jul 2004 04:32 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:53 PM.