title: Open only .xls files in a given directory using macro
body: <p>Just wondering... I have a piece of code - a macro in excel that allows me to open files in a given directory. The thing is that I only want to open .xls files, and the code that I have opens all the files in a given directory.</p>
  
  <p>Can anyone help me with this matter.</p>
  
  <p>Thanks.</p>
  
  <pre><code>Sub FindOpenFiles()
  Dim FSO As Scripting.FileSystemObject, folder As Scripting.folder, file As Scripting.file, wb As Workbook
  Dim directory As String
  
      directory = "O:\test"
  
      Set FSO = CreateObject("Scripting.FileSystemObject")
      Set folder = FSO.GetFolder(directory)
  
      For Each file In folder.Files
          Workbooks.Open file
      Next file
  End Sub
  </code></pre>