How can I tell if something is an object or a variable in the Microsoft Scripting Runtime library? I ask b/c I believe that in order to use an object, you need to declare a new instance of an object; however, based on what I can compile below, it does not look like I need to declare a new instance of a file in order to use it.
When I declare fil: Dim fil As Scripting.File...
...I do not need to declare a new instance of fil as I would with an object such as a collection or a file system object:
Dim fso As Scripting.FileSystemObject
Set fso = New Scripting.FileSystemObject
But if a file isn't an object, why can I use a For - Each - Next syntax that I thought was reserved for looping over collections of objects?
So I can write:
Dim fso As Scripting.FileSystemObject
Set fso = New Scripting.FileSystemObject
Dim fil As Scripting.File
For Each fil In fso.GetFolder(FolderPathGoesHere)
'/Do something to/with file: fil
Next fil
Bookmarks