Solved

How to delete a text file from the macro?

Posted on 2011-03-18
2
252 Views
Last Modified: 2012-06-22
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
0
Comment
Question by:Thomas_Meyer
2 Comments
 
LVL 12

Accepted Solution

by:
Amick earned 500 total points
Comment Utility
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
 

Author Closing Comment

by:Thomas_Meyer
Comment Utility
Thanks, perfect.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
This video shows the viewer how to set up and create Footnotes in their document. Click on the References tab: Select "Insert Footnote": Type in desired text:
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now