title: DIR function and Naming Tables in Access
body: <p>I am using the DIR function to import a set of excel files into access.  I then pass the attributes of the DIR to make the name of the table in access the same as the excel file.  The only problem is that I also get xls in the name how I can I stop this?</p>
  
  <p>Code below:</p>
  
  <pre><code>Sub Sample2()
  Const cstrFolder As String = "F:\TCB_HR_KPI\Data View\"
  Dim strFile As String
  Dim i As Long
  
  strFile = Dir(cstrFolder &amp; "*.xls")
  If Len(strFile) = 0 Then
  MsgBox "No Files Found"
  Else
  Do While Len(strFile) &gt; 0
      Debug.Print cstrFolder &amp; strFile
  
      DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel9, _
      strFile, cstrFolder &amp; strFile, True
  
      i = i + 1
      strFile = Dir()
  Loop
  MsgBox i &amp; " Files are imported"
  End If
  End Sub
  </code></pre>