title: how to convert excel file to CSV file (pipe delimited) using excel vba
body: <p>I want to convert the simple excel files into CSV(pipe delimited)
  using excel vba
  I tried to many code but cant get expected output </p>
  
  <pre><code>following code I tried
  
        Sub mergeFiles()
          Dim xlwkbInput1  As Workbook
          Dim xlshtInput1  As Worksheet
          Dim xlwbfinalrpt As Workbook
          Dim xlshtfinalrpt As Worksheet
  
          Dim rcount1 As Long
  
          Dim xlwkbInput2  As Workbook
          Dim xlshtInput2 As Worksheet
          Dim xlapp As Excel.Application
  
  
          Set xlapp = New Excel.Application
          xlapp.Visible = True               
  
             Set xlwkbInput1 = xlapp.Workbooks.Open(ActiveWorkbook.Path &amp; "\Output\Operative_CashFlow_Report.xlsx")
             Set xlwkbInput2 = xlapp.Workbooks.Open(ActiveWorkbook.Path &amp; "\Output\Collection_CashFlow_Report.xlsx")
  
             xlwkbInput2.Sheets("Sheet1").Activate
             xlwkbInput2.ActiveSheet.UsedRange.Copy
  
             xlwkbInput1.Sheets("Sheet1").Activate
             rcount = xlwkbInput1.ActiveSheet.UsedRange.Rows.Count
  
             xlwkbInput1.Sheets("Sheet1").Range("A" &amp; CStr(rcount + 1)).PasteSpecial
  
             xlwkbInput1.UsedRange("$A$1:$I$274").AutoFilter Field:=1, Criteria1:=Array( _
             "LIC106", "LIC107", "LIC134", "LIC138", "="), Operator:=xlFilterValues
             xlwkbInput1.UsedRange.Delete             
             xlwkbInput1.SaveAs ActiveWorkbook.Path &amp; "\Output\final_report.xlsx"              
             Set xlwbfinalrpt = xlapp.Workbooks.Open(ActiveWorkbook.Path &amp; "\Output\final_report.xlsx")       
             xlwbfinalrpt.Sheet("Sheet1").Activate
  
              xlwbfinalrpt.SaveAs ActiveWorkbook.Path &amp; "\Output\final_report.xlsx"      
  
      xlwbfinalrptwb = Workbooks.Open (ActiveWorkbook.Path &amp; "\Output\final_report.xlsx" 
  
           xlwbfinalrptwb .SaveAs fileName:=ActiveWorkbook.Path &amp; "\Output\final_report.xlsx"
      , FileFormat:=xlCSV, CreateBackup:=False  
  </code></pre>
  
  <p>' here I m doing conversion of excel to CSV file </p>
  
  <pre><code>End Sub
  </code></pre>