Kill a opened Excel File

  • Thread starter Thread starter Shazi
  • Start date Start date
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
 
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)
 
Back
Top