Answered Export excel sheet as text file with macro code

  • Tuesday, September 26, 2006 8:32 AM
     
     

    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 

All Replies

  • Tuesday, September 26, 2006 2:32 PM
     
     Answered

    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 3:58 PM
     
     

    Thanks a lot, it works like a sharm!