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/