What causes VB6 "Runtime Error" 5: Invalid procedure call or argument "

In VB6, users sometimes get this error, and I cannot reproduce it.

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

I refer to the "MSWord 10 object library", and sometimes this error occurs at some point after the application opened MSWord 2002. However, this application has for many years referenced the MSWord 10 object library, and this error has only just begun in recent years. several months.

I suppose I introduced a mistake somewhere, but I don’t know what might cause it. The error does not occur very often and cannot be reproduced by the user when I stand there. The error will cause the application to shut down completely.

Users are running Windows XP

+4
source share
2 answers

From memory using VB6 (now using .net), this may indicate that there is not enough memory on the user's computer or that your code could not get the dictionary application descriptor.

If you cannot create a problem in Visual Studio and don’t know which line in the code is causing the problem, then you are probably best off adding an error handler around the code that causes the problem.

At the top of the south, which has problems, put

  On Error GoTo MyErrorHandler 

and then on the bottom line

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

Instead of using MsgBox, as I here, consider writing to a file. Also, for Erl to work correctly, taking into account the numbering of each of your lines.

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

+5
source

This may be a problem with the β€œspeed”, in which the user launches Word / your form several times and disables the modal display error ( http://support.microsoft.com/kb/242347 ). For example, are you shelling an application or displaying it in a container window? Is it possible that they become impatient and press the / button several times? Try to press the button a few times quickly or set the focus by pressing a few times.

If you need to process / block a few clicks (easier) or preload Office to minimize the delay in initializing the application.

0
source

Source: https://habr.com/ru/post/1304259/


All Articles