How do you replace an existing file, saying "yes" in a macro?

C

Chris

Ok, I have a macro set up that creates an excel file using
different criteria. I have it create 5 "alternatives"
that each is a different file. After 5, you are not
allowed to create any more. If you try to create another
one, a message box pops up saying, do you want to replace
the existing file? The file already exists, and if you
say "no", or hit "cancel", my macro bombs out because of
the saveas property. Here is an example of my code:

ActiveWorkbook.SaveAs ("C:\" & pname & "-" & tod_month
& "_" & tod_day & "_" & tod_year & "_" & Alt_Name)

ActiveWorkbook.Close

It always bombs out at the SaveAS line. Any help would be
greatly appreciated. Email me if you have a solution.
Thanks!
 

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

Top