Delete a Folder to include subfolders & files

WatsonDyar

Registered User.
Local time
Yesterday, 23:44
Joined
Aug 12, 2014
Messages
50
I need a way to delete a folder along with subfolders and files associated with a record via command on a form:

The path is stored in a text field "txtDocuments".

For example: "C:\Users\Watson\Desktop\FY15\1505\1505-010"

So, I would want the code to pull the folder location from the txtDocuments text field and delete folder "1505-010" and all sub folders & files contained within it.

Making the directory was easy....deleting it is giving me the problem~

Thank you!
 
I need a way to delete a folder along with subfolders and files associated with a record via command on a form:

The path is stored in a text field "txtDocuments".

For example: "C:\Users\Watson\Desktop\FY15\1505\1505-010"

So, I would want the code to pull the folder location from the txtDocuments text field and delete folder "1505-010" and all sub folders & files contained within it.

Making the directory was easy....deleting it is giving me the problem~

Thank you!

Not a big problem really: look for example of fso.deletefolder on this page:

http://www.felicini.com/excel-vba/vba-deletefilesandfolders

Best,
Jiri
 
Thank you Jiri.

Question: If the path to the folder I want to delete is stored within a field associated with that record (in my case txtDocuments), how do use VBA to refer to it?

Use the Dir function?

Thanks again!
 
Thank you Jiri.

Question: If the path to the folder I want to delete is stored within a field associated with that record (in my case txtDocuments), how do use VBA to refer to it?

Use the Dir function?

Thanks again!

Hi, WD
In the link given, in the Sub Delete_Whole_Folder() you could either refer to you variable directly or - easier for you - assign MyPath to your variable, like
Code:
MyPath=Me!txtDocuments
.

Best,
Jiri
 

Users who are viewing this thread

Back
Top Bottom