Delete file

yippie_ky_yay

Registered User.
Local time
Today, 01:33
Joined
Jul 30, 2002
Messages
338
Hello all,

I have programmed this button to convert and combine a couple of reports in Word. To achieve this, 2 files are created and then joined together in one.

Everything works great except the 2 files used for temporary purposes are still there because I don't know how to delete them. Can anyone help me with this? Also, if I'm programmatically going to create and delete files, is there anything I should be keeping in mind? (ie if the temp files should be manipulated on the users C drive or network drive...?)

All advice is welcome!

Thanks,

-Sean
 
I does not matter where you work with the files. Once the files are joined (created) ensure you are verifying the new file is created using the Dir() function. Then use the Kill statement to delete the "temp" file. Check the help files for Dir and Kill for all the options and examples that go with those functions.

HTH
 
Last edited:
Thanks ghudson,

both those functions are new to me! (I'm always happy to learn something new).

-Sean
 
A word of warning - be prudent in your use of the Kill statement - it takes NO PRISONERS.
 
Here is a sample of the Kill Statement in code:
Code:
Dim strFileName As String
strFileName = "c:\myfile.txt"
Kill strFileName
MsgBox (strFileName & " has been deleted")

' Or you could simply use Kill "c:\myfile.txt"
 

Users who are viewing this thread

Back
Top Bottom