Solved

How to delete a text file from the macro?

Posted on 2011-03-18
2
264 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

Office 365 Training for Admins - 7 Day Trial

Learn how to provision tenants, synchronize on-premise Active Directory, implement Single Sign-On, customize Office deployment, and protect your organization with eDiscovery and DLP policies.  Only from Platform Scholar.

Question has a verified solution.

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

Microsoft Office Picture Manager was included in Office 2003, 2007, and 2010, but not in Office 2013. Users had hopes that it would be in Office 2016/Office 365, but it is not. Fortunately, the same zero-cost technique that works to install it with …
I was prompted to write this article after the recent World-Wide Ransomware outbreak. For years now, System Administrators around the world have used the excuse of "Waiting a Bit" before applying Security Patch Updates. This type of reasoning to me …
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses

617 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