Greetings!
For the record, I have already checked multiple sources (including the Microsoft website) and cannot find an answer to this question. When all else fails, I know someone in the tek-tips community will have what I'm looking for!!
You typically see all file/folder processing as follows:
What I want to do, is reference a specific element in the collection by doing something like this...
I do know that this works...
But this does not...
Nor anything in this list...
I do not want to load each file path in an internal array just so I can reference by number.
Any ideas of how I can reference a specific folder in the objFolders collection by simply referencing the element by number???
He who has knowledge spares his words, and a man of understanding is of a calm spirit. Even a fool is counted wise when he holds his peace; when he shuts his lips, he is considered perceptive. - King Solomon
For the record, I have already checked multiple sources (including the Microsoft website) and cannot find an answer to this question. When all else fails, I know someone in the tek-tips community will have what I'm looking for!!
You typically see all file/folder processing as follows:
Code:
Set objFileSys = CreateObject("Scripting.FileSystemObject")
For Each objFolder In objFileSys.GetFolder("C:\").SubFolders
Msgbox objFolder.Path
Next
What I want to do, is reference a specific element in the collection by doing something like this...
Code:
Set objFileSys = CreateObject("Scripting.FileSystemObject")
Set objFolders = objFileSys.GetFolder("C:\").SubFolders
Msgbox objFolders(3).Path
I do know that this works...
Code:
Set objFileSys = CreateObject("Scripting.FileSystemObject")
Set objFolders = objFileSys.GetFolder("C:\").SubFolders
Msgbox objFolders.Item("Program Files")
Msgbox objFolders("Program Files")
But this does not...
Code:
Set objFileSys = CreateObject("Scripting.FileSystemObject")
Set objFolders = objFileSys.GetFolder("C:\").SubFolders
Msgbox objFolders.Item(3)
Nor anything in this list...
Code:
Msgbox objFolders("3")
Msgbox objFolders.Item("3")
Msgbox objFolders.Key(3)
Msgbox objFolders.Key("3")
Any ideas of how I can reference a specific folder in the objFolders collection by simply referencing the element by number???
He who has knowledge spares his words, and a man of understanding is of a calm spirit. Even a fool is counted wise when he holds his peace; when he shuts his lips, he is considered perceptive. - King Solomon