Closing a Secondary Spreadsheet With a Macro

  • Thread starter Thread starter jim evans
  • Start date Start date
J

jim evans

I'm creating a macro that opens another spreadsheet, make some changes
to it, them saves it out to a text file.

I've got it all working except . . .

The nature of Excel loads the text file after/when saving it and, for
some reason, thinks I've changed it. So when I try to close it a "Do
you want to save changes?" prompt box pops up. The macro does not
record my clicking No, so this prompt box interrupts and otherwise
automatic process.

How do I deal with this prompt so the process is fully automatic?

jim
 
Try:

Application.DisplayAlerts = FALSE

before your save, and:

Application.DisplayAlerts = TRUE

after it.

Hope this helps.

Pete
 
And if you get that message when you're closing the workbook...

wkbk.close savechanges:=false
or
workbooks("book.xls").close savechanges:=false
 
Thanks for your reply.

Maybe I wasn't applying it properly, but I couldn't get this to work.
It did no harm but didn't help either.


Try:

Application.DisplayAlerts = FALSE

before your save, and:

Application.DisplayAlerts = TRUE

after it.

Hope this helps.

Pete


jim
 
Thanks.

workbooks("book.xls").close savechanges:=false did the trick.

And if you get that message when you're closing the workbook...

wkbk.close savechanges:=false
or
workbooks("book.xls").close savechanges:=false


jim
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top