Solved

How to delete a text file from the macro?

Posted on 2011-03-18
2
262 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 12

Accepted Solution

by:
Amick earned 500 total points
ID: 35165602
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
ID: 35165842
Thanks, perfect.
0

Featured Post

Windows running painfully slow? Try these tips..

Stay away from Speed Up Computer Programs that do more harm than good.
Try these tips instead.
Step by step instructions in trouble shooting Windows Performance issues.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
This video shows where to find the word count, how to display it, and what it breaks down to in Microsoft Word.
Learn how to create and modify your own paragraph styles in Microsoft Word. This can be helpful when wanting to make consistently referenced styles throughout a document or template.

752 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