HowTo delete from MS Access 2000 an XLS file.

Gerrit.B

Board Regular
Joined
Aug 10, 2004
Messages
237
Office Version
  1. 2019
  2. 2016
Platform
  1. Windows
I created a MS Access 2000 database, I import .xls files that I after importing want to delete.
Any Suggestion How? :oops:
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
I hava a file (123456.xls on E:\Documenten\Gerrit\123456.xls)
Where can i find KILL.
Can this be done by a macro ?
Can you provide me with a sample.
 
Upvote 0
It's a visual basic command that duplicates a DOS capability (delete).
You have to open up a Module and create a Subroutine/Function that does it.

This should be a thorougly confusing line of code but:
This is stripped out of another series of subroutines (most of it removed) but basically, this subroutine is passed the path to a given file. It first tests to see whether the path (file) exists via the ValidateLocations function, and then Kills it. the sSleep function is just a custom function that makes it wait 1 second.

Code:
Sub LoopKill(sDestFile As String)
 
 If ValidateLocations(sDestFile) Then
   Kill (sDestFile)
   sSleep (1000)
 End If

End Sub

Public Function ValidateLocations(ByVal strLoc As String) As Boolean

Dim lngType As Long

    ValidateLocations = Len(Dir(strLoc, lngType)) > 0

End Function
 
Upvote 0
Solved with funtion below and bat file
************************
Option Compare Database


Function fncDelFile()
Dim intStart As Integer
intStart = Shell("C:\xx\xx\Delfile.bat")
End Function

************************

(Delfile.bat)
@echo off
del C:\xx\xx\filename2delete.*

************************
 
Upvote 0
Gerrit,

All you had to do was:

Code:
Function fncDelFile() 

Kill ("C:\xx\xx\filename2delete.*")

End Function

Using batch files is, well, messy. And it limits you to being forced to set them up. The purpose of my original function was to allow you to pass values (the path to the file) so you can delete ANY file by code without creating batch files.

Mike
 
Upvote 0

Forum statistics

Threads
1,221,798
Messages
6,162,027
Members
451,737
Latest member
MRASHLEY

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top