Kill a opened Excel File

S

Shazi

Hi,

1. Please let me know how to kill the opened file permanently by a
macro.


and I have an other folder name TempReports on C:\shahzad\reports
\TempReports


2. I want to delete all files of the TempReports folder at once by
running a single macro.

please send me reply, thanks in advance.

Regards.

Shahzad
 
C

Chip Pearson

Try

1)
With Workbooks("Book4.xls")
.ChangeFileAccess xlReadOnly
Kill .FullName
End With

2)
Dim FF As Object
Dim FSO As Object
Set FSO = CreateObject("Scripting.FileSystemObject")
Set FF = FSO.getfolder("C:\Test")
FF.Delete

This will destroy the folder C:\Test and all its contents. If you want
to folder C:\Test to remain, use MkDir to create it after deletion.

Dim FF As Object
Dim FSO As Object
Set FSO = CreateObject("Scripting.FileSystemObject")
Set FF = FSO.getfolder("C:\Test")
FF.Delete
MkDir "C:\Test"


Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group, 1998 - 2009
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top