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

前端 未结 4 1833
心在旅途
心在旅途 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:18

    Just a necro solution: I have found the Close #1 method to still leave a truncated file. Instead, or in addition to, use the Application.Quit for Excel to close Excel. This flushes the cache and completes the write to the text file.

提交回复
热议问题