Word 宏错误消息
我正在更改文档模板宏。 我不知道该怎么做的一件事是自定义错误消息。 例如,文档中的错误消息是
“错误!未找到图表条目”
我想更改此消息以显示其他内容。 是否可以使用 Word VBA 或 VBScript 来完成此操作?
I am changing document template macros. The one thing I can't find out how to do is to customize error messages. For example an error message in a document is
"Error! No table of figures entries found"
I would like to change this to display something else. Is it possible to do this with Word VBA or VBScript?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这是可能的。 这是一个非常粗略的例子。
在标准模块中:
一些代码:
It is possible. Here is a very rough example.
In a standard module:
Some code:
如果要在 VBA 中捕获特定错误类型,一种方法是使用 On Error Resume Next,然后在要捕获的操作后面的行上测试错误消息,例如:
如果您知道确切的错误号 (
If Err.Number = N 那么
),那当然更好。If you want to trap a specific error type in VBA, one method is to use On Error Resume Next then test for an error message on the line following the action to trap, e.g.:
If you know the exact error number (
If Err.Number = N Then
), that would be better of course.好吧,如果您正在谈论拥有一个自定义消息框 - 那很简单。
在 VBA 帮助中查找“msgbox”以获得更好的信息。
16 使其成为一条“批评”消息。
如果您正在谈论错误捕获,那么您将需要这样的代码:
当抛出错误时,将向 Err 对象提供一个数字和描述。
Well if you are talking about having a custom message box - that's easy.
Look up 'msgbox' in VBA help for better info.
The 16 makes it a 'criticial' message.
If you're talking about error trapping then you'll need code like this:
When an error is thrown, a number and description are given to the Err object.