Passing a for-each object to a sub or function in vba
<p>When I call the sub pFileName I get an 'object required' error with the following code:</p>

<pre><code>Sub test()
Dim fs As Object
Dim csv As Object
Dim oFolder As Object

Set fs = CreateObject("Scripting.FileSystemObject")
Set oFolder = fs.getfolder(Application.CurrentProject.Path)

For Each csv In oFolder.files
    Debug.Print csv.Name
    pFname (csv)
Next csv
End Sub

Sub pFname(ByVal csv As Object)
    Debug.Print (csv.Name)
End Sub
</code></pre>

<p>I'm not sure why csv isn't considered an object - doesn't the Debug.Print statement right before the sub call prove it is an object?</p>