错误 goto [label] 在 VBA 中不起作用
在我的一个 Excel 工作簿中,我创建了一个包含以下行的宏:
On Error GoTo saltaw
Open fileout For Output As #iFileNumber
但是,当 fileout
包含一些无效字符(例如“\”)时,宏将停止并出现错误窗口“运行时错误' 76': 未找到路径”出现,就好像 on error goto
行不存在一样。如果我用on error resume next
替换on error goto
,情况也是如此。宏在下一行停止。为什么?
In one of my Excel workbooks I have created a macro containing the following lines:
On Error GoTo saltaw
Open fileout For Output As #iFileNumber
However, when fileout
contains some invalid chars ("\", for example) the macro stops and the error window "Runtime error '76': Path not found" appears, as if the on error goto
line does not exist. Same if I substitute on error goto
by on error resume next
. The macro stops at the following line. Why?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
转到
工具 ->选项->常规
并将错误捕获
设置为更适合您的其他内容。Go to
Tools -> Options -> General
and setError Trapping
to something else that better suits you.