Delete excel spreadsheet from code.

marathonlady

Registered User.
Local time
Today, 06:20
Joined
Jul 10, 2002
Messages
120
How do I delete an excel spreadsheet via code? I run a query that creates the spreadsheet, but when I run it again it will not overlay the spreadsheet, it makes a second copy. I either need code to delete before I create, or overlay it. I am using the TransferSpreadsheet method of the docmd.

Thanks for for any help.
 
I will delete the excel file before I do a Transferspreadsheet.

Dim delfile
On error resume next
docmd.setwarnings false
delfile = "d:\data\excel\myfile.xls"
kill delfile

Docmd.transferspreadsheet .................

docmd.setwarnings true

Note : If the file does not exist, you will not get error message, because of 'On error resume next'
 

Users who are viewing this thread

Back
Top Bottom