VBA 中遇到一些奇怪的错误
我正在做 powerpoint 2007 自动化项目。我正在使用宏编程(VBA)。运行宏时出现以下错误。
Err.Number= -2147024809 (80070057)
但我关心的不是错误,因为我想捕获此错误并基于此错误我想执行一些操作。
这就是为什么我尝试像这样编写错误处理代码:
OnError Goto Err:
'some code
Err:
If Err.number = -2147024809 (80070057) then
'do something
end if
Resume next
所以基本上,如果我以这种方式编写错误号,那么它就不允许它。它给出了错误。
最重要的是,当错误发生时,它不会出现“Err:”。它只是弹出带有“结束”和“调试”选项的错误。
I am doing project in powerpoint 2007 automation. In that i am using macro programming (VBA). I am getting the following error while run the macro.
Err.Number= -2147024809 (80070057)
but my concern is not with error Because i want to catch this error and base on this error i want to perform some action.
Thats why i try to code like this for error handing code:
OnError Goto Err:
'some code
Err:
If Err.number = -2147024809 (80070057) then
'do something
end if
Resume next
So bascially if i write error number in this way then its not allow it. it gives error.
and major thing is when error occurs sometime it did not go to "Err : ". It just pop-up error with "End" and "Debug" options.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
虽然它似乎有效,但一方面,我对使用保留对象名称(Err)作为标签持谨慎态度。
如果您需要捕获可能仅在代码中的某些位置发生的非常具体的错误,您还可以执行本地错误处理程序:
While it seems to work, I'd be cautious about using a reserved object name (Err) as a label, for one thing.
If you need to trap very specific errors that might occur only at certain places in your code, you can also do a local errorhandler:
错误号是数字:
-2147024809
,为了清楚起见,它只是显示为字符串"-2147024809 (80070057)"
( 80070057)
是十六进制的错误号。你想要;
或者如果你这样选择
Error numbers are numeric:
-2147024809
, its just displayed to you as the string"-2147024809 (80070057)"
for clarity(80070057)
being the error number in hexadecimal.You want;
or if you so choose
错误消息的
80070057
部分是负数-2147024809
的无符号十六进制版本。删除代码的这一部分就可以了,如果您想跟踪数字的十六进制版本(对于通过 Google 等研究错误很有用),那么只需将其添加为注释即可。The
80070057
part of the error message is the unsigned hexadecimal version of the negative number-2147024809
. Remove that part of your code and you will be fine, if you want to keep track of the hex version of the number (can be useful for researching errors via Google etc) then just add it as a comment.