Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Close workbook without being prompted to save in VBA

I am using the following code to close and save a workbook:

Application.DisplayAlerts = False
ActiveWorkbook.Close SaveChanges:=True

I can't seem to get this to work without prompting me to save, even though I
did application.displayalerts = false and I told it to save in the
active.workbook.close command.
  #2   Report Post  
Posted to microsoft.public.excel.programming
TG TG is offline
external usenet poster
 
Posts: 8
Default Close workbook without being prompted to save in VBA

On Dec 19, 10:36 pm, J Wait wrote:
I am using the following code to close and save a workbook:

Application.DisplayAlerts = False
ActiveWorkbook.Close SaveChanges:=True

I can't seem to get this to work without prompting me to save, even though I
did application.displayalerts = false and I told it to save in the
active.workbook.close command.


I made it work with

ActiveWorkbook.Save
ActiveWorkbook.Close

/Tommy
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default Close workbook without being prompted to save in VBA

Do you have any "on close" event code. If so then it may be altering the
workbook which will prompt the save message. You can use Activeworkbook.Saved
= true to make the application believe that a save is not necessary...
--
HTH...

Jim Thomlinson


"J Wait" wrote:

I am using the following code to close and save a workbook:

Application.DisplayAlerts = False
ActiveWorkbook.Close SaveChanges:=True

I can't seem to get this to work without prompting me to save, even though I
did application.displayalerts = false and I told it to save in the
active.workbook.close command.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Close workbook without being prompted to save in VBA

I tried what you said to begin with, and even though I told it to save before
I told it to close, it still prompted me to save on the close command. I
don't know what else to try. I've never run into this problem before.

I have also tried "ActiveWorkbook.Close True", and it still prompts me to
save.

To answer Jim's question, I don't have any "on close" event code, so I can't
try what he suggested.

Please let me know if you have any other ideas I could try. I'm hung up on
this one piece of the code!

"TG" wrote:

On Dec 19, 10:36 pm, J Wait wrote:
I am using the following code to close and save a workbook:

Application.DisplayAlerts = False
ActiveWorkbook.Close SaveChanges:=True

I can't seem to get this to work without prompting me to save, even though I
did application.displayalerts = false and I told it to save in the
active.workbook.close command.


I made it work with

ActiveWorkbook.Save
ActiveWorkbook.Close

/Tommy

  #5   Report Post  
Posted to microsoft.public.excel.programming
TG TG is offline
external usenet poster
 
Posts: 8
Default Close workbook without being prompted to save in VBA

On Dec 19, 10:59 pm, J Wait wrote:
I tried what you said to begin with, and even though I told it to save before
I told it to close, it still prompted me to save on the close command. I
don't know what else to try. I've never run into this problem before.

I have also tried "ActiveWorkbook.Close True", and it still prompts me to
save.

To answer Jim's question, I don't have any "on close" event code, so I can't
try what he suggested.

Please let me know if you have any other ideas I could try. I'm hung up on
this one piece of the code!

"TG" wrote:
On Dec 19, 10:36 pm, J Wait wrote:
I am using the following code to close and save a workbook:


Application.DisplayAlerts = False
ActiveWorkbook.Close SaveChanges:=True


I can't seem to get this to work without prompting me to save, even though I
did application.displayalerts = false and I told it to save in the
active.workbook.close command.


I made it work with


ActiveWorkbook.Save
ActiveWorkbook.Close


/Tommy


The reason could be a formula containing NOW() or TODAY() as these are
changing ' on the fly' and therefore the worksheet believe it has
changed, and must be saved on closing..

Maybe this will work, I haven't tried yet

ActiveWorkbook.Save
ActiveWorkbook.Saved
ActiveWorkbook.Close

/Tommy



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Close workbook without being prompted to save in VBA

Thank you so much Tommy and Jim! Here's what ended up working:

ActiveWorkbook.Save
ActiveWorkbook.Saved = True
ActiveWorkbook.Close

You solved a huge headache for me! Thanks!

"TG" wrote:

On Dec 19, 10:59 pm, J Wait wrote:
I tried what you said to begin with, and even though I told it to save before
I told it to close, it still prompted me to save on the close command. I
don't know what else to try. I've never run into this problem before.

I have also tried "ActiveWorkbook.Close True", and it still prompts me to
save.

To answer Jim's question, I don't have any "on close" event code, so I can't
try what he suggested.

Please let me know if you have any other ideas I could try. I'm hung up on
this one piece of the code!

"TG" wrote:
On Dec 19, 10:36 pm, J Wait wrote:
I am using the following code to close and save a workbook:


Application.DisplayAlerts = False
ActiveWorkbook.Close SaveChanges:=True


I can't seem to get this to work without prompting me to save, even though I
did application.displayalerts = false and I told it to save in the
active.workbook.close command.


I made it work with


ActiveWorkbook.Save
ActiveWorkbook.Close


/Tommy


The reason could be a formula containing NOW() or TODAY() as these are
changing ' on the fly' and therefore the worksheet believe it has
changed, and must be saved on closing..

Maybe this will work, I haven't tried yet

ActiveWorkbook.Save
ActiveWorkbook.Saved
ActiveWorkbook.Close

/Tommy


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
Excel - No Longer Prompted to Save When I Close File HammerD Excel Discussion (Misc queries) 1 May 8th 09 06:05 PM
Open New Workbook / Save and Close Current Workbook Joe K. Excel Programming 1 December 7th 07 08:04 PM
"Save" macro problem, still prompted to save when closing workbook (?) StargateFanFromWork[_4_] Excel Programming 8 September 13th 06 04:49 PM
Help on Workbook close and workbook save events Adam Harding Excel Programming 1 September 29th 05 04:12 PM
filling a combobox (without being prompted to save the workbook EVERY time its opened neowok[_34_] Excel Programming 2 March 1st 04 03:39 PM


All times are GMT +1. The time now is 07:46 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"