Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Programatically delete an excel file after its been imported

Status
Not open for further replies.

GooGoocluster

Technical User
May 12, 2005
71
US
I have a spreadsheet that gets generated every night that needs to be deleted when access is through importing it, its there a way to have this done with out user interaction.

Also this spreadsheet tends to have duplicate information I have a key setup so it does not import those records but its has an error message that pops up. can I also set it to disregard any errors and just import?

Thanks in advance!
 
Have a look at the Kill VBA instruction and at the DoCmd.SetWarnings method.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Have a look here it might help you

thread 702-1146035
 
Thanks to both of you for findings those I did a search and I dont beliave I saw those. anyway it worked great!

setwarnings = no works half way, it elimatnated the duplicate record error. but if there is no file to update it still brings up an error saying file does not exist.

I want to try to have no human intraction becuase this will be an update that happens every night.

is there a way to have it check for the file first then if its there then execute?

Thanks again you guys you really helped so far!
 
You could try something like:

If Dir("c:\mypath\myfile.xls") <> "" Then
DoCmd.SetWarnings False
Kill "c:\mypath\myfile.xls"
DoCmd.SetWarnings True
End If


Hope this helps.

[vampire][bat]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top