错误 goto [label] 在 VBA 中不起作用

发布于 2024-10-01 02:32:52 字数 333 浏览 1 评论 0原文

在我的一个 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

羅雙樹 2024-10-08 02:32:52

转到工具 ->选项->常规并将错误捕获设置为更适合您的其他内容。

Go to Tools -> Options -> General and set Error Trapping to something else that better suits you.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文