How can I write to a text file reliably from Excel VBA?

前端 未结 4 1867
心在旅途
心在旅途 2021-01-11 10:31

I\'m trying to use Excel VBA to write to a text file. I\'m doing a few of these:

MyFile1 = \"C:\\outputFromExcel1.txt\"
fnum1 = FreeFile()
Open MyFile1 For          


        
4条回答
  •  无人及你
    2021-01-11 11:07

    Have you considered writing the text to a different sheet (or a different workbook) and then using:

    ActiveWorkbook.SaveAs Filename:="C:\MyFile.txt", FileFormat:=xlText
    

    Not sure if this would give you better results (in terms of performance and/or formatting), but perhaps worth a try.

提交回复
热议问题