Delete current workbook + parent folder

Kelvin Stott

Active Member
Joined
Oct 26, 2010
Messages
338
Hi, I have been struggling to write some VBA code (tried many variations) that will close the workbook in which the VBA code runs, then delete the workbook itself as well as the entire folder that contains it. The problem is the code can’t delete the workbook and folder unless and until the workbook is closed, but the code itself stops running when the workbook is closed so it also won’t delete the workbook and folder. How to allow the VBA code to keep running and delete the workbook and folder after the workbook containing the VBA code is closed???
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
Put the code in your PERSONAL.XLSB workbook and run it from a button on the Quick Access Toolbar.
 
Upvote 0
Thanks, but I need to keep the code integrated within the workbook itself, so that the workbook effectively deletes itself and the folder that contains it. So I was wondering if the VBA code can be made to continue running after the workbook that contains it is closed?
 
Upvote 0
Thanks, but I need to keep the code integrated within the workbook itself, so that the workbook effectively deletes itself and the folder that contains it. So I was wondering if the VBA code can be made to continue running after the workbook that contains it is closed?
Don't know. Try it on a copy of the workbook.
 
Upvote 0

Forum statistics

Threads
1,214,985
Messages
6,122,602
Members
449,089
Latest member
Motoracer88

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top