Hey VB Gurus .... this code snippet yields an error and I am baffled as to why. As I type the line "oFolder.Files.Item(i).Name" each part of it appears for you to select so I know it is valid syntactically, but it yields an error when run. I tried starting i at 1 and at 0, but still yields error - and yes there are files in that folder. Any help would be greatly appreciated. Thanks
Dim fs As Scripting.FileSystemObject
Dim oFolder As Scripting.Folder
Set fs = New Scripting.FileSystemObject
sTPath = "\some valid path"
Set oFolder = fs.GetFolder(sTPath)
for i = 0 to oFolder.Files.count
msgbox oFolder.Files.Item(i).Name
next i
yields ....
Error 5: Invalid procedure call or argument.
Dim fs As Scripting.FileSystemObject
Dim oFolder As Scripting.Folder
Set fs = New Scripting.FileSystemObject
sTPath = "\some valid path"
Set oFolder = fs.GetFolder(sTPath)
for i = 0 to oFolder.Files.count
msgbox oFolder.Files.Item(i).Name
next i
yields ....
Error 5: Invalid procedure call or argument.