Releasing Claim on Folder (VBA/Word/2003)

I am using VBA to recognize a folder and its contents with the following process:<UL><LI>Create or identify a folder (Folder A);
<LI>Determine whether Folder A contains a subfolder (A/[img]/forums/images/smilies/cool.gif[/img] and if necessary create it
<LI>Copy a file to Folder A
<LI>Determine the contents of subfolder AB[/list]Later the user may run another macro intended to delete Folder A and all of its contents. using the following command: <pre>Shell "cmd /c ""rd """ & Folder2Delete & """ /s /q"""</pre>

If Folder A was the last folder to be recognized, the code does not delete the folder though it does delete all of the contents. Can any loungers suggest a technique to cause Word VBA to release its claim on a given folder, thereby allowing deletion of that specific folder?

Re: Releasing Claim on Folder (VBA/Word/2003)

<P ID="edit" class=small>(Edited by wdwells on 18-Oct-07 18:19. "be" added to last paragraph.)</P>Hi Hans
First off; apologies. I am attaching a module that was missing from the package I provided earlier. The project compiled successfully because a copy of the missing module was held in my Normal template.

What should you look at? Please take a look at the attached module and advise if there is anything therein that you feel might lock a folder.

I have just run the following series of tests on my D: drive which contains among other items an empty folder named "D:TrashTrashx". The following commands were executed from the Immediate window of the VBE unless otherwise stated.

<LI> mkdir "D:trashtrash" The folder was created as requested.
<LI> rmdir "D:trashtrash" The folder was deleted as requested
<LI> mkdir "D:trashtrash" The folder was created as requested.
<LI> A file was placed in "D:trashtrash" using Windows Explorer
<LI> The file was deleted from "D:trashtrash" using the keyboard Delete key
<LI> Windows Explorer was taken up one level to display the contents of "D:trash"
<LI> rmdir "D:trashtrash" The folder was deleted as requested
<LI> mkdir "D:trashtrash" The folder was created as requested.
<LI> A file was placed in "D:trashtrash" using Windows Explorer
<LI> ?dir("D:trashtrash*.*") Returned the file name
<LI> The file was deleted from "D:trashtrash" using the keyboard Delete key
<LI> Windows Explorer was taken up one level to display the contents of "D:trash"
<LI> rmdir "D:trashtrash" An error message appeared Run Time Error 75. Path/File Access Error
<LI> ?dir("D:trashx*.*") Returned a null string.
<LI> rmdir "D:trashtrash" The folder was deleted as requested

From the foregoing i understand that the Dir command can lock a folder--and be used to unlock it. Are you aware of any other VBA commands which pose the same threat?