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 Shaun E 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 Run DEL A:\*.* from a Macro

Status
Not open for further replies.

stotzc001

Technical User
Mar 27, 2003
30
US
I have a macro that outputs reports to a floppy disk, however I want to check to see if the disk is empty before I do this, and if it is not, erase the contents of the disk. I tried using RunApp, but have had limited success. I think the solution is probably found in a vba function, but that is over my head.
 
Hi

The function to tell you if any files exist is DIR(), and KIll will delete a file

So

Dim FileName as String
Filename = Dir("A:\*.*")
Do until Filename = ""
Kill FileName
Dir
Loop

to understand what is going on here see help for the DIR() function, but briefly
DIR("A:\*.*") returns the first file on the floppy, or "" if the floppy is empty
Kill deletes that file
DIR by itself after a DIR(path) returns the next file matching the search path, so the loop will continue until all files on the floppy have been deleted

Hope this helps Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top