Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
if workbooks exists delete
Hi Folks,
I have a simple little problem where before my macro create a temp file by a certain name, I want it to check if that file already exists and if it does, delete it. I have code that will delete the temp file as one of the finishing touches on the procedure, but occasionally the program won't run all the way through and upon autorecovery it needs user input asking if you want to overright the existing file. I'd rather simply check for it and remove it if exists before getting to that point. TIA! |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
if workbooks exists delete
Function IsFileThere() As Boolean
Dim fso As Object Set fso = CreateObject("Scripting.Filesystemobject") If fso.FileExists("C:\CertainFileName.xls") Then' Your file name goes there with full path IsFileThere = True Else IsFileThere = False End If End Function On 4 Dec, 14:40, Stephen wrote: Hi Folks, I have a simple little problem where before my macro create a temp file by a certain name, I want it to check if that file already exists and if it does, delete it. I have code that will delete the temp file as one of the finishing touches on the procedure, but occasionally the program won't run all the way through and upon autorecovery it needs user input asking if you want to overright the existing file. *I'd rather simply check for it and remove it if exists before getting to that point. TIA! |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
if workbooks exists delete
Look up the "Kill Statement" in VB's help files.
-- Rick (MVP - Excel) "Stephen" wrote in message ... Hi Folks, I have a simple little problem where before my macro create a temp file by a certain name, I want it to check if that file already exists and if it does, delete it. I have code that will delete the temp file as one of the finishing touches on the procedure, but occasionally the program won't run all the way through and upon autorecovery it needs user input asking if you want to overright the existing file. I'd rather simply check for it and remove it if exists before getting to that point. TIA! |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
if workbooks exists delete
Try just setting
appliation.displayalerts = false just prior to the save. Taht will stop the alert message. Set it back to true when the save is complete Application.DisplayAlerts = false ThisWorkbook.SaveAs "C:\Tada.xls" Application.DisplayAlerts = true -- HTH... Jim Thomlinson "Stephen" wrote: Hi Folks, I have a simple little problem where before my macro create a temp file by a certain name, I want it to check if that file already exists and if it does, delete it. I have code that will delete the temp file as one of the finishing touches on the procedure, but occasionally the program won't run all the way through and upon autorecovery it needs user input asking if you want to overright the existing file. I'd rather simply check for it and remove it if exists before getting to that point. TIA! |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
if workbooks exists delete
brilliant! thank you much!!!
"Jim Thomlinson" wrote: Try just setting appliation.displayalerts = false just prior to the save. Taht will stop the alert message. Set it back to true when the save is complete Application.DisplayAlerts = false ThisWorkbook.SaveAs "C:\Tada.xls" Application.DisplayAlerts = true -- HTH... Jim Thomlinson "Stephen" wrote: Hi Folks, I have a simple little problem where before my macro create a temp file by a certain name, I want it to check if that file already exists and if it does, delete it. I have code that will delete the temp file as one of the finishing touches on the procedure, but occasionally the program won't run all the way through and upon autorecovery it needs user input asking if you want to overright the existing file. I'd rather simply check for it and remove it if exists before getting to that point. TIA! |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
If Pivot Table Exists, Delete on Close | Excel Programming | |||
If sheet exists, delete | Excel Programming | |||
Check for a shape - then change or delete it if it exists | Excel Programming | |||
Copy from multiple workbooks, rename, and overwrite if exists | Excel Programming | |||
If worksheet exists delete | Excel Programming |