none
Saving Excel as text file RRS feed

  • Question

  • I have a macro to save my Excel file as a tab-delimited text file after all other macros execute. However, there is always a blank line at the end of the text file. I have to go into the text file and delete. While this is not really that painful to do it would be nice if the macro could do it for me when it saves. Is there a way to have my save as text file macro remove the blank line?

    Thanks.

    Friday, March 27, 2015 3:27 PM

Answers

  • I have a macro to save my Excel file as a tab-delimited text file after all other macros execute. However, there is always a blank line at the end of the text file. I have to go into the text file and delete. While this is not really that painful to do it would be nice if the macro could do it for me when it saves. Is there a way to have my save as text file macro remove the blank line?

    Thanks.

    You need to change the last statement where you append the string from. Note the semi-colon

    Print #1, txt

    To

    Print #1, txt;



    Friday, March 27, 2015 3:35 PM
  • Another way.You can try this .NET API to convert, set the space character as you like:

    • code:
         Workbook workbook = new Workbook();
         workbook.LoadFromFile(@"..\ExceltoTxt.xls");
         Worksheet sheet = workbook.Worksheets[0];
         sheet.SaveToFile("ExceltoTxt.txt", " ", Encoding.UTF8);

    Tutorials.

    as text


    Monday, March 30, 2015 6:30 AM

All replies

  • I have a macro to save my Excel file as a tab-delimited text file after all other macros execute. However, there is always a blank line at the end of the text file. I have to go into the text file and delete. While this is not really that painful to do it would be nice if the macro could do it for me when it saves. Is there a way to have my save as text file macro remove the blank line?

    Thanks.

    You need to change the last statement where you append the string from. Note the semi-colon

    Print #1, txt

    To

    Print #1, txt;



    Friday, March 27, 2015 3:35 PM
  • Another way.You can try this .NET API to convert, set the space character as you like:

    • code:
         Workbook workbook = new Workbook();
         workbook.LoadFromFile(@"..\ExceltoTxt.xls");
         Worksheet sheet = workbook.Worksheets[0];
         sheet.SaveToFile("ExceltoTxt.txt", " ", Encoding.UTF8);

    Tutorials.

    as text


    Monday, March 30, 2015 6:30 AM