错误时转到[标签]在VBA中不起作用 [英] on error goto [label] not working in VBA

查看:118
本文介绍了错误时转到[标签]在VBA中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的一本Excel工作簿中,我创建了一个包含以下几行的宏:

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

但是,当fileout包含一些无效的字符(例如,"\")时,宏停止,并且出现错误窗口运行时错误'76':找不到路径",就像on error goto行未出现一样存在.如果将on error goto替换为on error resume next,则相同.宏在下一行停止.为什么?

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?

推荐答案

转到Tools -> Options -> General并将Error Trapping设置为更适合您的其他内容.

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

这篇关于错误时转到[标签]在VBA中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆