Auto answer - "Do you wish to save changes"

  • Thread starter Thread starter Peter
  • Start date Start date
P

Peter

Hi,

I have a script that copies a worksheet, creates a new workbook
containing the copied sheet which is then printed. After printing the
new workbook is closed

The script is:

ActiveSheet.Copy

'Next line prints out the new worksheet

ActiveWorkbook.PrintOut

'Next line closes the workbook containing the copied worksheet

ActiveWorkbook.Close

Obviously when I close the new (and temporary) workbook I'm prompted
with the question "Do I wish to save the changes to book 2?"

Is it possible to get the script to effectively answer that question
for me - so the question doesn't appear?


--
Cheers

Peter

Remove the INVALID to reply
 
Application.DisplayAlerts=False
newbook.Saved=True
newbook.Close

this will close without attempting to sav
 
Hi Peter

Use this if you not want to save the file

ActiveWorkbook.Close False
 
But why don't you use

ActiveSheet.PrintOut

Instead of copy it first to a new workbook
 
But why don't you use

ActiveSheet.PrintOut

Instead of copy it first to a new workbook

I did it in the way I described because the workbook contains lots of
sheets and i only wanted the one to be emailed (and printed) - Assumed
that if I asked for a print that it would print all the sheets. Will
try your suggestion.

Many thanks


--
Cheers

Peter

Remove the INVALID to reply
 
Application.DisplayAlerts=False
newbook.Saved=True
newbook.Close

this will close without attempting to save

Hi,

many thanks for your reply.


--
Cheers

Peter

Remove the INVALID to reply
 
Hi Peter

Use this if you not want to save the file

ActiveWorkbook.Close False

Hi Ron,

I've tried out your solution and it works perfectly - many thanks for
taking the time to help


--
Cheers

Peter

Remove the INVALID to reply
 

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