PDA

View Full Version : Open a subfolder deeper than the first



Evil
02-12-2010, 08:51 AM
Hi: This code opens, in the Windows Explorer, a subfolder of the folder c:\Misc\ with a name beginning with "Web":


Private Sub CommandButton1_Click()
Dim obj As Object
Set objFileSystem = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFileSystem.GetFolder("c:\Misc\")
Set objSubFolders = objFolder.SubFolders
For Each obj In objSubFolders
If InStr(obj.Name, "Web") > 0 Then
Shell "explorer.exe """ & obj.Path & "", vbMaximizedFocus
Else
End If
Next
End Sub

However, it does that only if the subfolder named a name beginning with "Web" is the first subfolder of the folder c:\Misc\.

What I want is to open the subfolder named a name beginning with "Web" no matter how deep it is, in the folder/subfolder structure, inside the folder c:\Misc\.

How do I make it do that?

Thanx for your help.