Using Microsoft Access 2003 VBA Code to delete an Excel Workbook

Posted on 2011-04-27
Medium Priority
Last Modified: 2012-08-13
I have a button on a form in my DB that creates an Excel Spreadsheet to display data to the end user. It saves this Excel file on the local hard drive in a specific location. After the user closes it, the data is no longer useful.  Before the user runs the next instance of this, I would like Access to delete the previous Excel file before creating the new one.

The path and file name are always a constant, so they can be specified on the script.  For specific reasons, I do not want the script to just overwrite the previous file the next time the user runs it.  I need to have it deleted.  Is there VBA Code I can add at the beginning of my script to delete the file first?  
Question by:jmcclosk
LVL 33

Accepted Solution

jppinto earned 500 total points
ID: 35477187
Just like this:

Kill  "C:\YourFolder\YourFileName.xls"

Author Closing Comment

ID: 35477290
Thank you!

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
A quick solution showing how to control and open a POS Cash Register Drawer using VBA with MS Access.
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
The Relationships Diagram is a good way to get an overall view of what a database is keeping track of. It is also where relationships are defined. A relationship specifies how two tables connect to each other. As you build tables in Microsoft Ac…

616 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question