Do loop until no more folder is found

  • Thread starter Thread starter Piotr (Peter)
  • Start date Start date
P

Piotr (Peter)

Hi,

I'm writing on behalf of my colleague who needs to write a loop that opens
folders within a folder X until no furhter folder is found in that folder X.

Any help highly appreciated.
 
Thanks Alex for this. It has been slightly amended so that the code ignores
folders "." and "..", which are normally taken into account due to the way
the code "sees" folders and I presume is back to DOS era (code below).

Dim strFolder As String

strFolder = Dir(fnWskazFolder, vbDirectory)
Do While Len(strFolder) > 0
If strFolder = "." Then
strFolder = Dir
End If
If strFolder = ".." Then
strFolder = Dir
End If

Debug.Print strFolder
strFolder = Dir
Loop


Thanks everybody for your contribution.

Regards,
Peter
 
Back
Top