"Word automation error 5" and VB6

H

Hugo Faber

Hi,

I have previously done a post in some under newsgroups.

My problem is as follows:
- I have an VB6 application wshich is able to generate reports using
Word automation
- Early binding has been used
- Reference in the VB6 project is made to Word 8 library (msword8.olb)
- The report generation runs well on my machine (Office 2003).
- The application doesnt run well on 2 other machines (office 97 and
Office 2000).

I got an automation error 5 ("invalid procedure call or argument") on
both machines at the same lines in my code,

with Range.Find do
...
....
.Execute Replacement:=wdReplaceAll => error 5
...
wend


and

...
moDocument.TablesOfContents(1).Update => error 5

Does anyone has experience with this error? I have learned that a
trick to eliminate error 5 is to add a DoEvents statement before the
failing Word automation statement. Does anyone has experience with
that?

I have also discovered that a DLL containing the Word automation part
had been still compiled with symbolic debug information, so I have
recompiled my application. Could this make any difference in the
runtime behavior wrt Word automation?

Best regards,
Hugo
 
T

Tom Winter

In Word 97/8.0, Replacement is not a valid parameter to the Execute method
of the Find object. As far as I can tell, it's not either in Word 2003/11.0.
Are you sure you have the code right in your post?

Other than that, it sounds like you are doing things correctly. Not sure
what you would get that error. Perhaps try switching to late binding for
these two calls and see if that helps.

You also might want to post in a Word newsgroup for a better shot at getting
an answer.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top