ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How do you replace an existing file, saying "yes" in a macro? (https://www.excelbanter.com/excel-programming/282979-how-do-you-replace-existing-file-saying-yes-macro.html)

Chris

How do you replace an existing file, saying "yes" in a macro?
 
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!


All times are GMT +1. The time now is 01:26 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com