VBA: delete a folder from pc

Nelson78

Well-known Member
Joined
Sep 11, 2017
Messages
526
Office Version
  1. 2007
Hello everybody.

I've created a folder called FileNameFolder.
At the end of the process, I need to delete it (and whatever there is inside) from my pc.
How can I figure it out?


VBA Code:
Dim oApp As Object
Set oApp = CreateObject("Shell.Application")
oApp.Namespace(FileNameFolder).CopyHere oApp.Namespace(Fname).items

'do stuff

'then I need to delete the folder
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
To delete the folder, you can use FileSystemObject...

VBA Code:
Dim fso As Object
Set fso = CreateObject("Scripting.FileSystemObject")
fso.DeleteFolder FileNameFolder

Hope this helps!
 
Upvote 0
Run-time error '76': Path Not Found

on

VBA Code:
fso.DeleteFolder FileNameFolder

Yet, the path seems correct (the folder does exist).
 
Upvote 0
Does this link help?

 
Upvote 0

Forum statistics

Threads
1,215,471
Messages
6,125,002
Members
449,202
Latest member
Pertotal

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