edfreels
asked on
How to delete certain Excel Workbooks in a folder
Hello Experts!
I am wanting to check a folder that contains Excel Workbooks that are no longer needed, and Delete them. I have scoured the boards here and have not found what I am looking for. Is there a way to search a filepath and delete the unwanted books? I appreciate your help on this. Thanks,
I am wanting to check a folder that contains Excel Workbooks that are no longer needed, and Delete them. I have scoured the boards here and have not found what I am looking for. Is there a way to search a filepath and delete the unwanted books? I appreciate your help on this. Thanks,
You would need to use a KILL command:
Kill strFilePathName
Leon
Kill strFilePathName
Leon
Kill works with out the need to reference the File System Object
Leon
Leon
ASKER
Okay saurabh726, I am looking for a C# solution, and leonstryker. The KILL command is not recognized with my C#, and, doesn't that simply close or terminate any open specified apps? Or, does is perform a delete as well? Just curious. The error I get with the KILL,...."The name "KILL" does not exist in the current context.
Well, you posted this in the Excel area as well as C# and both of us are looking at this question from that side, which to us means VBA. In any case, Kill is a Shell command so from C# you would need to run it as such. Not being too familiar with C#, I am not too sure how it is done.
Leon
Leon
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Sorry about the delay, I have been bogged down with something else; Thanks leonstryker for the solution, it works wonderfully.
To use this code, You need to have Microsoft scripting runtime selected in library under-->Tools-->references
Saurabh...
Open in new window