Thread: Deletefolder
View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips[_6_] Bob Phillips[_6_] is offline
external usenet poster
 
Posts: 11,272
Default Deletefolder

Like this?

Dim fso, folderobj, fldr
Const fsoReadonly As Long = 2

Set fso = CreateObject("Scripting.FileSystemObject")
Set folderobj = fso.GetFolder("c:\myTest")
For Each fldr In folderobj.subFolders
If Not fldr.Attributes And fsoReadonly Then
fldr.Delete
End If
Next fldr


--

HTH

RP
(remove nothere from the email address if mailing direct)


"Alvin Hansen" wrote in message
...
Hi bob thanks
CAn i instead of a name say if folder is readonly then
dont delete.
i have try with
fso.deletefolder "c:\" & tt & tal & kur1 & "\*", False
its working with my files but not on folders
If the folders is emty it dele the folder if the folder have a file with
readonly then
i get permission denied error
So the only thing i nead is if the folder is read only then dont delete

regards alvin

"Bob Phillips" skrev:

You have to iterate through all the folders

Set FolderObj = fso.GetFolder("c:\" & tt & tal & kur1)
For each fldr in FolderObj.SubFolders
If fldr.name < "special" Then
fldr.delete
End If
Next fldr

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Alvin Hansen" wrote in message
...
HI!

I use this:
fso.deletefolder "c:\" & tt & tal & kur1 & "\*.*"
its allright but if there are one folder i dosn't want to delete
how can i do that?

Befor the delefolder i have :

Set FolderObj = fso.GetFolder("c:\" & tt & tal & kur1) to see if there

are
folders

Best regards alvin