none
Export excel sheet as text file with macro code

    Question

  • Hi,

    How do I export a specific excel sheet (say sheet1) as a text file? I would like to do this with macro code.

    Grateful for ideas on this.

    \Jonas 

    Tuesday, September 26, 2006 8:32 AM

Answers

  • This code will do it:

    Sheet1.SaveAs "C:\output path\output file.txt", <format>

    The <format> parameter is of type XlFileFormat; for a CSV text file, use xlCSV or xlCSVMSDOS.  The VBA documentation enumerates all the possible format options.

    Tuesday, September 26, 2006 2:32 PM

All replies

  • This code will do it:

    Sheet1.SaveAs "C:\output path\output file.txt", <format>

    The <format> parameter is of type XlFileFormat; for a CSV text file, use xlCSV or xlCSVMSDOS.  The VBA documentation enumerates all the possible format options.

    Tuesday, September 26, 2006 2:32 PM
  • Thanks a lot, it works like a sharm!

    Tuesday, September 26, 2006 3:58 PM