我对VBA很陌生。我在 <header> 上搜索了很多,但我仍然不明白。
这是我的示例代码:
Sub test()
a = 10
b = 2
c = 10 / b
Debug.Print c
On Error GoTo x
x:
If Err > 1 Then
Debug.Print "The most recent error number is " & Err & _
". Its message text is: " & Error(Err)
End If
End Sub
如何将即时窗口的输出写入文本文件,或者如果有任何错误写入 errorlog.txt 文件?
我尝试了这样的一点:
sub test()
dim gofs:set gofs=createobject("scripting.filesystemobject")
dim tsout:set tsout=gofs.createtextfile(output)