title: Save text files with same name as Excel files
body: <p>I have a Visual Basic script that converts excel files to text files.  Let's say I have an excel file called example.xlsx; currently, the script saves it as example.xlsx.txt, which isn't what I want.  I need it to save as: example.txt</p>
  
  <p>Any ideas? </p>
  
  <pre><code>Option Explicit
  
      Dim oFSO, myFolder
  Dim xlTXT
  
  myFolder="C:\..."
  
  
  Set oFSO = CreateObject("Scripting.FileSystemObject")
  xlTXT = 21 'Excel TXT format enum
  Call ConvertAllExcelFiles(myFolder)
  Set oFSO = Nothing
  
  Call MsgBox ("Done!")
  
  
  Sub ConvertAllExcelFiles(ByVal oFolder)
  Dim targetF, oFileList, oFile
  Dim oExcel, oWB, oWSH
  
      Set oExcel = CreateObject("Excel.Application")
      oExcel.DisplayAlerts = False
      Set targetF = oFSO.GetFolder(oFolder)
      Set oFileList = targetF.Files
      For Each oFile in oFileList
          If (Right(oFile.Name, 4) = "xlsx") Then
              Set oWB = oExcel.Workbooks.Open(oFile.Path)
              For Each oWSH in oWB.Sheets
                  Call oWSH.SaveAs (oFile.Path &amp; ".txt", xlTXT )
                  Exit For
              Next
              Set oWSH = Nothing
              Call oWB.Close
              Set oWB = Nothing
          End If
      Next
      Call oExcel.Quit
      Set oExcel = Nothing
  
  End Sub
  </code></pre>