dhirensharma
asked on
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.Applica tion")
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:
comctl32.ocx
COMDLG32.OCX
TABCTL32.OCX
VB6 Runtime & OLE Automation
Could anybody tell me the possible reason be for the application to report this error?
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.Applica
Set newdoc = Wrd.Documents.Open("c:\abc
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:
comctl32.ocx
COMDLG32.OCX
TABCTL32.OCX
VB6 Runtime & OLE Automation
Could anybody tell me the possible reason be for the application to report this error?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
The best way to open the word file through vb is simply use shell function
Try this
------------
command1_click()
Shell "c:\program files\microsoft office\office\winword.exe " & "c:\abc.doc", vbNormalFocusend sub
-------------------
Hope this will help u
rengards
Rengarajan
Software Engineer
CI.Com
Try this
------------
command1_click()
Shell "c:\program files\microsoft office\office\winword.exe " & "c:\abc.doc", vbNormalFocusend sub
-------------------
Hope this will help u
rengards
Rengarajan
Software Engineer
CI.Com
ASKER
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.Applica tion")
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:\leg al\APA.doc ")
as pointed out by ryancys. This worked.
Would appreciate if anybody could tell me the difference in the 2 methods.
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.Applica
Set newdoc = Wrd.Documents.Open("c:\abc
hasn't been solved yet. I used:
Dim wrd as word.application
Set newdoc = wrd.Documents.Open("c:\leg
as pointed out by ryancys. This worked.
Would appreciate if anybody could tell me the difference in the 2 methods.
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.
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.
dhirensharma:
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?
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
Split points between: ryancys and Richie_Simonetti
DanRollins -- EE database cleanup volunteer
Dim wrd as word.application