vba - 如何将 VBA Debug.Print 输出记录到文本文件?

标签 vba

Possible Duplicate:
Any way to automatically move contents of immediate window into a text file?

是否可以将 Debug.Print 输出记录到文本文件而不是 Excel VBA 中的立即窗口?

最佳答案

您应该看到 Jean-François Corbett 的精彩回答 here :

正如他所说,当您可以同时写入输出 txt 文件(或者只是 txt 文件,如果这是您想要的)时,写入立即窗口,然后复制并粘贴它没有什么意义。 .

他的回答示例:

Dim s As String
Dim n As Integer

n = FreeFile()
Open "C:\test.txt" For Output As #n

s = "Hello, world!"
Debug.Print s ' write to immediate
Print #n, s ' write to file

Close #n

关于vba - 如何将 VBA Debug.Print 输出记录到文本文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13853376/

相关文章:

vba - 另存为 PDF,在年月文件夹下

vba 如果单元格包含任何格式的字符串

excel - 在 VBA 中逐行读取/解析文本文件

excel - 仅复制和粘贴可见单元格

sql-server - 无 DSN 连接 MS Access 前端和 SQL 服务器后端

excel - 在两个电子表格上复制和选择性粘贴

excel - 如何将Excel工作表中的列格式设置为数字格式?

html - 如何使用 VBA 单击网站上的组合框

vba - If 语句移动单元格

excel - 一个单元格中的串联数据;当 1 条信息不存在时删除整行