How to delete a text file from the macro?

Hi,

do not know how a simple macro that checks at startup if the computer is a text file on path: "%temp%\test.log" and if so, delete it?
I found this, but I do not know exactly how to use it:

http://www.exceltip.com/st/Basic_file_and_folder_examples_using_VBA_in_Microsoft_Excel/443.html

Thanks for your help
Thomas_MeyerAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
AmickConnect With a Mentor Commented:
In the Developer->Visual Basic tab select This Workbook and copy the following code:
Private Sub Workbook_Open()
sTemp = Environ("TEMP")
Kill sTemp + "\test.log"
End Sub

Open in new window


Save the workbook in a trusted directory so that the macro will run upon loading or be sure to enable macros for the workbook when it is opened.
0
 
Thomas_MeyerAuthor Commented:
Thanks, perfect.
0
All Courses

From novice to tech pro — start learning today.