Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

RMDIR (deleting folder) problem

Status
Not open for further replies.

MikeCDPQ

Technical User
Sep 11, 2003
173
CA
I have a script where user is prompted a few questions then the script creates folders, saves excel files and emails them. It works beautifully. I want to offer the user the possibility of deleting the folder once the files have been mailed because those files are temporary and useless after they have been sent.

The confirmation msgbox below shows the right path which I copied to the RMDIR portion.
This is what the path looks like:
(G:\Department Shared Data\Purchasing\COMMON\60DAYS PERIOD 10FY04 NEW3).

The problem is although the folder does exist I get error message: Run time error '75':path/File access error.

Here is the portion of the script:

'Remove 60 Days directory
If Dir(&quot;G:\Department Shared Data\Purchasing\COMMON\&quot; + &quot;60DAYS PERIOD &quot; & whatperiod & &quot;FY&quot; & Right(whatyear, 2) & &quot; &quot; & WhichVersion, vbDirectory) <> &quot;&quot; Then
confirmDel60 = msgbox(&quot;Do you wish to delete: &quot; & &quot;G:\Department Shared Data\Purchasing\COMMON\&quot; + &quot;60DAYS PERIOD &quot; & whatperiod & &quot;FY&quot; & Right(whatyear, 2) & &quot; &quot; & WhichVersion, vbYesNo)
If confirmDel60 = 6 Then
RmDir &quot;G:\Department Shared Data\Purchasing\COMMON\&quot; + &quot;60DAYS PERIOD &quot; & whatperiod & &quot;FY&quot; & Right(whatyear, 2) & &quot; &quot; & WhichVersion
End If

Any suggestions anyone
 
Mike,

You will need to remove any files that are in the directory first. I have just tested this out and I get the same error if I try to remove the directory if there are files still in it, but it works fine if it is empty.

HTH

Matt
[rockband]
 
This seems to be the perfect thread to re-introduce my FAQ:

faq707-4116 - File and Folder Procedures

Check it out, you might find it interesting! ;-)



Peace!! [peace]

Mike

Didn't get the answers that you wanted? Take a look at FAQ219-2884
 
Thanks everybody,

All I needed was these two lines and it works beautifully.

Set fs = CreateObject(&quot;Scripting.FileSystemObject&quot;)
fs.deletefolder &quot;G:\Department Shared Data\Purchasing\COMMON\&quot; + &quot;60DAYS PERIOD &quot; & whatperiod & &quot;FY&quot; & Right(whatyear, 2) & &quot; &quot; & WhichVersion

Thanks a bunch.

Mike
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top