Delete Excel Spreadsheet

  • Thread starter Thread starter Martin
  • Start date Start date
M

Martin

Hi,

Is there any way to write a macro in Access to delete an
excel spreadsheet that is stored in a specific location?
Basically I am exporting some records to excel and doing
some bits and pieces to them. I then want that file
erased for data protection purposes.

Cheers

Martin
 
Martin,

I do not know of a way to do this with a macro, but it is very easy to do it
with a single line of VB code.
Paste the following function in any existing Module, or create a new one:

Function Delete_WorkBook()
Kill "C:\SomeFolder\SomeWorkBook.xls"
End Function

Just change the string in quotes to the actual path and filename.

Then the function can be run form a macro using a RunCode action, with
argument Delete_WorkBook(), or from a command button on a form etc.

HTH,
Nikos
 
Back
Top