Jan 12, 2007 #1 elmorro Programmer Jun 23, 2005 133 US I have an excel file that I need to delete when my program is ran. I tried using the following code: Kill "C:\ExcelFile.xls" but it did not work. How can I accomplish this. Thanks in advance, elmorro
I have an excel file that I need to delete when my program is ran. I tried using the following code: Kill "C:\ExcelFile.xls" but it did not work. How can I accomplish this. Thanks in advance, elmorro
Jan 12, 2007 #2 HughLerwill Programmer Nov 22, 2004 1,818 GB Did you get an error message; if so what was it? Upvote 0 Downvote
Jan 12, 2007 #3 Golom Programmer Sep 1, 2003 5,595 CA Usually you want Code: FN = "C:\ExcelFile.xls" If Dir(FN) <> "" Then Kill FN "Kill" will raise an error if you attempt to use it on a file that doesn't exist. Upvote 0 Downvote
Usually you want Code: FN = "C:\ExcelFile.xls" If Dir(FN) <> "" Then Kill FN "Kill" will raise an error if you attempt to use it on a file that doesn't exist.
Jan 12, 2007 Thread starter #4 elmorro Programmer Jun 23, 2005 133 US HughLerwill, I kept getting an access denied error. But I change file path and it works now. Thanks. Upvote 0 Downvote
Jan 12, 2007 Thread starter #5 elmorro Programmer Jun 23, 2005 133 US Golom, Thanks for the code. I am also using the following code to save the file: objWorkBook.SaveAs "C:\ExcelFile.xls" But if the file is an existant file it pops the following message: The file already exists, would you like to replace it? Is there anyway to stop this message from appearing? Thanks in advance, elmorro Upvote 0 Downvote
Golom, Thanks for the code. I am also using the following code to save the file: objWorkBook.SaveAs "C:\ExcelFile.xls" But if the file is an existant file it pops the following message: The file already exists, would you like to replace it? Is there anyway to stop this message from appearing? Thanks in advance, elmorro
Jan 12, 2007 #6 Swi Programmer Feb 4, 2002 1,963 US Just use Golom's code before your code: Code: FN = "C:\ExcelFile.xls" If Dir(FN) <> "" Then Kill FN objWorkBook.SaveAs FN Swi Upvote 0 Downvote
Just use Golom's code before your code: Code: FN = "C:\ExcelFile.xls" If Dir(FN) <> "" Then Kill FN objWorkBook.SaveAs FN Swi
Jan 15, 2007 Thread starter #7 elmorro Programmer Jun 23, 2005 133 US Thanks Swi, I will do as you suggested. elmorro Upvote 0 Downvote