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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I delete a file using VBA?

Status
Not open for further replies.

ARJakhu

Technical User
Sep 8, 2002
8
GB
Hi all,

I have a problem with macros and batch files. I have one macro named "EXECUTE" in MS ACCESS 2000 which sequentialy kicks off 4 other macros in total. The first of these macros calls a batch file to perform some file copying, renaming and moving functions on the A: drive. The problem is that the EXECUTE macro moves on to the next macro and starts it without waiting for the batch file to finish running. Is there any way around this?

I also want to delete the batch file on the A: drive once a macro that has used it has finished running. Can anyone show me how this can done in VBA?

ARJakhu
 
Your first problem can be solved by running the 4 macros from VBA code and having a DoEvents command between each one.

As for deleting files, I believe the correct syntax is
Code:
kill
strFilename
.

Hope this helps.

--Ryan
 
Thanks Ryan,

Being a bit of a novice, I'm still having problems!

I tried the kill statment as

Kill "A:\SET_DISK.BAT"

Which returns an error: Run-time error 28: Out of stack space

Is this me or it?

 
Um... I believe you've got the syntax right... Is your floppy disk write-protected?
 
Thanks for replying so quickly Ryan.

The disk is not protected but i've noticed that when I enter the Kill statment in VBA, it no longer converts to the correct case and shows the correct syntax balloon. Has the error affected something in VBA? All the other commands and function seem to work OK.

As for the DoEvent function... could you show me an example because I have tried following the example from the help file and that does not work either.

Jakhu
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top