title: VBA Excel get first file name from the files collection returned by GetFolder.Files
body: <p>I'm trying to get the first file of a directory. I don't care that "first" is not well defined in this case, and I don't care if I'll get a different file each time I call my sub.</p>
  
  <p>I try to use:</p>
  
  <pre><code>Dim FSO As Object
  Dim SourceFolder As Object
  
  Dim FileItem As Object
  
  Set FSO = CreateObject("Scripting.FileSystemObject")
  Set SourceFolder = FSO.GetFolder(SourceFolderName)
  
  Set FileItem = SourceFolder.Files.Item(0)
  </code></pre>
  
  <p>but this returns a compiler error ("Invalid procedure call or argument")
  Could you please tell me how to make this work? </p>
  
  <p>Thanks,
  Li</p>