Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 202
  • Last Modified:

Run-time error'-2147023067 (80070725)': Automation Error

I am working on a VB application to invoke Ms Word from a form & am working on a windows XP SP1 machine. I have Ms Office 97 & MSWORD8.OLB on the same machine on which I am developing the application.

The application invokes Word absolutely fine & the required document as well when I am in the development Environment (Visual Studio).

Following is the code that I have used:

Dim wrd
Set Wrd = CreateObject("Word.Application")
Set newdoc = Wrd.Documents.Open("c:\abc.doc")

The problem,

Run-time error'-2147023067 (80070725)': Automation Error

comes when I am trying to run the application on Windows Me machines. Those machines also have MS Office 97.

I have created the Setup and have not included the MSWORD8.OLB in the setup package.

The following are the other controls that are in the pack:

VB6 Runtime & OLE Automation

Could anybody tell me the possible reason be for the application to report this error?
1 Solution
Ryan ChongCommented:
Try add the M$ Word object library from your Reference first, then define the line:

Dim wrd as word.application
Richie_SimonettiIT OperationsCommented:
I think it is a problem of dll versions, something that is called "Dll Hell".
Tha P&D Wizard has packing sensitive controls like comctl32.ocx
which belongs to XP version of Windows and they are not "so compatible" with Me as we could wish.
The best way to open the word file through vb is simply use shell function

Try this
Shell "c:\program files\microsoft office\office\winword.exe " & "c:\abc.doc", vbNormalFocusend sub
Hope this will help u
Software Engineer
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

dhirensharmaAuthor Commented:
Hi guys,

Thanks. I apologise for the long gap in this reply.
The problem really was with the Dlls (atleast that is what I concluded).
The word library was included right at the outset. The original problem:

Dim wrd
Set Wrd = CreateObject("Word.Application")
Set newdoc = Wrd.Documents.Open("c:\abc.doc")

hasn't been solved yet. I used:

Dim wrd as word.application
Set newdoc = wrd.Documents.Open("c:\legal\APA.doc")

as pointed out by ryancys. This worked.
Would appreciate if anybody could tell me the difference in the 2 methods.
Richie_SimonettiIT OperationsCommented:
First use late-binding which means VB has no clue about what object you would create, it is slow and it carry out errors as you already know.
Second one is Early-binding which means that know need to set a reference to the used library in your project before use it. It is fastaer and you could catch errors at disign time and not when things are missed (like at run time)

It appears like XP doesn't like to create objects at run tme or maybe the lbary that gives CreateObject function is not available in target machine.
Try to use createObject with another object, just as a test, and see.
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
Experts: Post your closing recommendations!  Who deserves points here?
Moderator, my recommended disposition is:

    Split points between: ryancys and Richie_Simonetti

DanRollins -- EE database cleanup volunteer

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now