![]() |
Help with ActiveWorkbook.SaveAs
Hello,
The line below saves the current workbook, but errors if I have an existing workbook with the same name already. Is there an additional parameter that will overwrite the existing workbook with this new one? If not, how should I go about overwriting the existing workbook? I could put some code in to check if the workbook name already exist and name the new workbook appropriately, but I wanted to see if there was something simpler. Thanks. objExcel.ActiveWorkbook.SaveAs strOutputFilePath -- Regards, Martin X. MCSA: M |
Help with ActiveWorkbook.SaveAs
Precede the statement with
Application.DisplayAlerts = False "Martin X." wrote in message ... Hello, The line below saves the current workbook, but errors if I have an existing workbook with the same name already. Is there an additional parameter that will overwrite the existing workbook with this new one? If not, how should I go about overwriting the existing workbook? I could put some code in to check if the workbook name already exist and name the new workbook appropriately, but I wanted to see if there was something simpler. Thanks. objExcel.ActiveWorkbook.SaveAs strOutputFilePath -- Regards, Martin X. MCSA: M |
Help with ActiveWorkbook.SaveAs
Try something like:
On Error Resume Next Kill strOutputFilePath On Error Goto 0 objExcel.ActiveWorkbook.SaveAs strOutputFilePath This will delete the file named by strOutputFilePath if it exists and then does the SaveAs. Note that Kill permanently deletes the file. It does not send it to the Windows Recycle Bin. If you want to Recycle the file, see http://www.cpearson.com/excel/recycle.htm . -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting www.cpearson.com (email on the web site) "Martin X." wrote in message ... Hello, The line below saves the current workbook, but errors if I have an existing workbook with the same name already. Is there an additional parameter that will overwrite the existing workbook with this new one? If not, how should I go about overwriting the existing workbook? I could put some code in to check if the workbook name already exist and name the new workbook appropriately, but I wanted to see if there was something simpler. Thanks. objExcel.ActiveWorkbook.SaveAs strOutputFilePath -- Regards, Martin X. MCSA: M |
Help with ActiveWorkbook.SaveAs
Try following:
Application.DisplayAlerts = False Regards reklamo "Martin X." wrote: Hello, The line below saves the current workbook, but errors if I have an existing workbook with the same name already. Is there an additional parameter that will overwrite the existing workbook with this new one? If not, how should I go about overwriting the existing workbook? I could put some code in to check if the workbook name already exist and name the new workbook appropriately, but I wanted to see if there was something simpler. Thanks. objExcel.ActiveWorkbook.SaveAs strOutputFilePath -- Regards, Martin X. MCSA: M |
All times are GMT +1. The time now is 10:27 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com