Can't Delete Folder after creating it through VBA (1 Viewer)

Oreynolds

Member
Local time
Today, 22:59
Joined
Apr 11, 2020
Messages
157
Where in my code would I put that?

not sure if you’ve watched the full thread but I’m not trying to delete in VBA. I’m running VBA code to allow a user to create a folder and copy some files to it.

the problem occurs after that is complete as if the user then goes to delete the created folder/files through normal files manager they can’t.

if you press the reset button on the VBA editor you then can delete it despite it not showing any code is running.
 

strive4peace

AWF VIP
Local time
Today, 16:59
Joined
Apr 3, 2020
Messages
1,004
actually, maybe not ... you need to RELEASE the object variables in your code. I see you've put some statements in, but commented them. That is why resetting works -- what it is doing is releasing your objects.
 
Last edited:

strive4peace

AWF VIP
Local time
Today, 16:59
Joined
Apr 3, 2020
Messages
1,004
Oreynolds , close rs and release all objects after End With before Shell
 

onur_can

Active member
Local time
Today, 14:59
Joined
Oct 4, 2015
Messages
180
The following procedure completely deletes the folder and its contents.

Code:
Sub ODeleteFolderAndFiles()
Dim FileSys, strDir As String
Set FileSys = CreateObject("Scripting.FileSystemObject")
strDir = "D:\Test" 'Specify the path to the folder here
If FileSys.FolderExists(strDir) Then
FileSys.DeleteFolder strDir
End If
End Sub
 

Oreynolds

Member
Local time
Today, 22:59
Joined
Apr 11, 2020
Messages
157
can you try, Application.FollowHyperlink instead of shell.

OK, tried:

Application.FollowHyperlink ("FoldernameDest")

But still won't allow you to delete folder until RESET button in VBA pressed!
 

Users who are viewing this thread

Top Bottom