Unable to delete and Excel Workbook from VBA 
Author Message
 Unable to delete and Excel Workbook from VBA

When I attempt to delete an excel workbook from VBA, using the VBA Kill
command or the Scripting Runtime's FileSystemObject Object I get the
following error.

Run-time error '70':
Permission denied

I suspect that this is because excel has locked the file, thus preventing it
from being deleted.

The only way to delete the file is by Quitting and Relaunching Excel.

How can I make excel release the lock on the workbook file without quitting
excel or stopping the execution of the subroutine?



Sun, 18 Jul 2004 02:27:30 GMT  
 Unable to delete and Excel Workbook from VBA
I may be wrong but I think you can just close the Workbook without closing
Excel application and you should be able to delete the file.

If you close the Workbook and the delete the file straight away, you may
need to add the DoEvents statement to allow the O/S time to perform the
background tasks to actually release the lock on the Workbook.

HTH
Van T. Dinh


Quote:
> When I attempt to delete an excel workbook from VBA, using the VBA Kill
> command or the Scripting Runtime's FileSystemObject Object I get the
> following error.

> Run-time error '70':
> Permission denied

> I suspect that this is because excel has locked the file, thus preventing
it
> from being deleted.

> The only way to delete the file is by Quitting and Relaunching Excel.

> How can I make excel release the lock on the workbook file without
quitting
> excel or stopping the execution of the subroutine?



Sun, 18 Jul 2004 06:43:38 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. VBA: Excel workbook to workbook transfer

2. deleting worksheet in excel workbook

3. VBScript Item.Delete?, run Excel Workbook from public folder

4. how delete a macro within an Excel Workbook by using VB

5. how delete a macro within an Excel Workbook by using VB

6. Excel vba code not finding workbook, adds .xls extension

7. Extracting VBA modules from excel workbook

8. Populating a ListBox via a VBA macro when opening an Excel Workbook

9. Pasting Range from Excel 2002 via VBA to Word causes a New Workbook to open

10. Excel HRESULT: 0x800A03EC when using Workbooks.open or Workbooks._opentext in C#

11. Excel 97/2000: making custom functions (in a hidden workbook) available to all open workbooks

12. Excel VBA workbook app hangs on open/close

 

 
Powered by phpBB® Forum Software