我有一个输出到文本文件的Excel VBA宏。文本文件的底部总是有一个空白行,我很难摆脱它。任何有用的建议将不胜感激!谢谢
Sub testExport()
Dim fPath As String, exportTxt As String
fPath = CreateObject("WScript.Shell").SpecialFolders("Desktop") & "\Sample_" & Format(Now(), "HHNNSS") & ".txt"
exportTxt = "Project: Sample Output" & vbCrLf
exportTxt = exportTxt & "Model Version: 1 "
Open fPath For Append As #1 'write the new file
Print #1, exportTxt
Close #1
结束子
最佳答案
从Print #
语句的帮助以及输出数据后指定charpos
的方法中:
请尝试以下操作:
Print #1, exportTxt;
关于vba - 导出时Excel VBA在文本文件的末尾添加多余的空行,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/4017968/