是什么导致 VB6“运行时错误‘5’:无效的过程调用或参数”?

发布于 2024-08-25 12:04:14 字数 518 浏览 3 评论 0原文

在 VB6 中,用户偶尔会收到此错误,但我无法重现它。

运行时错误“5”:无效的过程调用或参数

我正在引用“MSWord 10 对象库”,有时在应用程序打开 MSWord 2002 后的某个时刻会发生此错误。但是,此应用程序引用了 MSWord 10 对象库多年来,这个错误只是在最近几个月才开始发生。

该代码使用以下内容对应用程序进行脱壳:

Dim app As Word.Application = GetObject("", "Word.Application")

我假设我在某处引入了错误,但不知道可能是什么原因造成的。该错误不会经常发生,并且当我站在那里时,用户无法重现该错误。该错误迫使应用程序完全关闭。

用户运行的是Windows XP。报告问题最多的用户是通过 Citrix 运行应用程序。共有 350 名用户,其中大约 100 名通过 Citrix 使用该应用程序。

关于如何修复错误有什么想法吗?

In VB6, users occasionally receive this error and I am unable to reproduce it.

Run-Time Error '5': Invalid Procedure Call or Argument

I am referencing the "MSWord 10 Object Library" and sometimes this error occurs at some point after the application has opened MSWord 2002. However, this app has referenced the MSWord 10 Object Library for years, and this error just started occurring in the last few months.

The code is shelling the app using the following:

Dim app As Word.Application = GetObject("", "Word.Application")

I am assuming I have introduced a bug somewhere, but no idea what might be causing it. The error does not occur very often and cannot be reproduced by a user when I am standing there. The error forces the app to totally shut down.

Users are running Windows XP. The user reporting the issue the most is running the app thru Citrix. There are 350 total users, about 100 use the app thru Citrix.

Any ideas on how fix the error?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(3

窗影残 2024-09-01 12:04:15

从 VB6 的内存(现在使用 .net)来看,这可能表明用户计算机内存不足,或者您的代码无法获取单词 app 的句柄。

如果您无法在 Visual Studio 中产生问题,并且不确定代码中的哪一行导致了问题,您最好在导致问题的代码周围添加错误处理程序。

在有问题的子顶部放置

   On Error GoTo MyErrorHandler

,然后在底部放置

   On Error Goto 0
   Exit Sub
MyErrorHandler:
   MsgBox "Error " & Err.Number & " (" & Err.Description & ") at line " & Erl

而不是像我在这里那样使用 MsgBox 考虑写入文件。另外,考虑到对每一行进行编号,Erl 也能正常工作。

对于 VB6,MZ 工具是一个很棒的插件链接,它将帮助您添加错误处理和行数字很​​容易

From memory with VB6 (now using .net) this can point at the users machine being low on memory or that your code has been unable to get a handle for the word app.

If you are unable to produce the problem within Visual Studio and unsure which line in your code is causing the issue you are probably best off adding an error handler around the code that is causing the problem.

At the top of the sub that has problems put

   On Error GoTo MyErrorHandler

and then at the bottom put

   On Error Goto 0
   Exit Sub
MyErrorHandler:
   MsgBox "Error " & Err.Number & " (" & Err.Description & ") at line " & Erl

Rather than using a MsgBox as I have here consider writing down to a file instead. Also for Erl to work correctly considering numbering each of your lines.

For VB6 a great plugin is MZ tools link which will help you add the error handling and line numbers really easily

单调的奢华 2024-09-01 12:04:15

这可能是一个“速度”问题,其中用户多次启动 Word/您的表单并引发模式显示错误 (http://support.microsoft.com/kb/242347)。例如,您是对应用程序进行脱壳还是将其显示在容器窗口中?他们是否可能变得不耐烦并点击按钮/不止一次?尝试快速单击按钮多次或设置焦点,反复按 Enter 键。

如果是这种情况,您将需要处理/阻止多次单击(更简单)或以某种方式预加载 Office,以最大程度地减少应用程序初始化时的延迟。

It may be a "speed" issue in which the user is launching Word/your form multiple times and tripping a modal display error (http://support.microsoft.com/kb/242347). e.g. Are you shelling the app or displaying it in a container window? Is it possible they are getting impatient and clicking the button/more than once? Try clicking the button more than once quickly or setting focus, hitting enter repeatedly.

If that's the case you will either need to handle/block the multiple clicks (easier) or preload Office in some way to minimize the delay while the app initializes.

羅雙樹 2024-09-01 12:04:15

我们在一个大型项目中遇到了这个错误。在我们的例子中,原因在于将焦点设置在当时不可见的对象上。 [虽然这里的情况并非如此,但我添加是因为此帖子包含许多导致错误 5 的潜在原因。]

We experienced this error in a large project. In our case, the cause turned out to be set focus on an object which at the time was not visible. [Tho not the case here, I'm adding because this posting contains a lot of potential causes for Error 5.]

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