ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Replace an Existing File (https://www.excelbanter.com/excel-programming/369785-replace-existing-file.html)

Jim Skrydlak

Replace an Existing File
 
I am working on an application in VBA that will read in yesterday's file,
save it as filename_OLD.xls, then replace the data in it with today's data
and save it as filename.xls. How do I replace the existing filename_OLD.xls
without having any messages or prompts appear? The VBA help tells me
everything except what I want to know. I've tried .SaveAs and doing a
..DeleteFile before saving the new version, but I've had problems with both.

Ron de Bruin

Replace an Existing File
 
Hi Jim

If you want to overwrite the file then you can use

Application.DisplayAlerts = False
'SaveAs code
Application.DisplayAlerts = True


--
Regards Ron de Bruin
http://www.rondebruin.nl



"Jim Skrydlak" wrote in message ...
I am working on an application in VBA that will read in yesterday's file,
save it as filename_OLD.xls, then replace the data in it with today's data
and save it as filename.xls. How do I replace the existing filename_OLD.xls
without having any messages or prompts appear? The VBA help tells me
everything except what I want to know. I've tried .SaveAs and doing a
.DeleteFile before saving the new version, but I've had problems with both.




Jim Skrydlak

Replace an Existing File
 
Thank you. Turns out that I was also trying to write to a directory to which
I had only read-access. Makes things difficult :-)

Jim

"Ron de Bruin" wrote:

Hi Jim

If you want to overwrite the file then you can use

Application.DisplayAlerts = False
'SaveAs code
Application.DisplayAlerts = True


--
Regards Ron de Bruin
http://www.rondebruin.nl



"Jim Skrydlak" wrote in message ...
I am working on an application in VBA that will read in yesterday's file,
save it as filename_OLD.xls, then replace the data in it with today's data
and save it as filename.xls. How do I replace the existing filename_OLD.xls
without having any messages or prompts appear? The VBA help tells me
everything except what I want to know. I've tried .SaveAs and doing a
.DeleteFile before saving the new version, but I've had problems with both.






All times are GMT +1. The time now is 12:14 PM.

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