I have a couple folders on my desktop which I used temporarily for a macro. Now, I want to delete them. One is a .zip and one is a regular folder.
Set fso = CreateObject("scripting.filesystemobject")
fso.DeleteFolder unzipPath, True
The above code works without error. The non-.zip folder is deleted without issues. This, however, does not remove the file:
On Error GoTo 0
fso.DeleteFolder zipPath, True
Contrary to the MSDN documentation, this does not create an error, either. After far too much time, I realized I simply needed to use DeleteFile
for the .zip, since apparently a .zip is technically a file, rather than a folder. Then both items are deleted successfully.
It works now, but I'm still a bit confused as to why using DeleteFolder
did not produce an error, though. The aforementioned documentation specifies
An error occurs if no matching folders are found.
UPDATE: For the sake of testing, I created a standalone sub exclusively to test the DeleteFolder
on a .zip. The .zip is unchanged; there is no error returned; the sub just ends.
Just a curious soul wandering the realms of VBA...