al4629740
asked on
Automation error the server threw an exception
I have a form in VB6 where I have an ADODC connection to my SQL Server Express 2019. On the form I have an export that takes the current recordset and creates report in Microsoft Word. This function works well on my home computers but when I use it at the office, I get the following error:
What exactly is Automation error mean and how do I locate the source of the problem?
Here is the export code that is causing the problem:
What exactly is Automation error mean and how do I locate the source of the problem?
Here is the export code that is causing the problem:
Private Sub Command1_Click()
Dim objMSWord As Word.Application
Dim myDOc As Word.Document
Dim oTable As Word.Table
Dim tb As Word.Shape
Dim r As Integer
Dim c As Integer
Set objMSWord = CreateObject("Word.Application")
Set myDOc = objMSWord.Documents.Open("http://xxxxxxxxxxx", ReadOnly:=False)
objMSWord.ActiveWindow.View = wdPrintView
objMSWord.ActiveDocument.Bookmarks("Address").Select
objMSWord.Selection.TypeText Adodc1.Recordset.Fields("Address")
objMSWord.ActiveDocument.Bookmarks("City").Select
objMSWord.Selection.TypeText Adodc1.Recordset.Fields("City")
objMSWord.ActiveDocument.Bookmarks("CompanyName").Select
objMSWord.Selection.TypeText Adodc1.Recordset.Fields("Name")
objMSWord.ActiveDocument.Bookmarks("ContactName").Select
objMSWord.Selection.TypeText Adodc1.Recordset.Fields("Contact")
objMSWord.ActiveDocument.Bookmarks("ContactName1").Select
objMSWord.Selection.TypeText Adodc1.Recordset.Fields("Contact")
objMSWord.ActiveDocument.Bookmarks("NumMonths").Select
objMSWord.Selection.TypeText Adodc1.Recordset.Fields("MS")
objMSWord.ActiveDocument.Bookmarks("Price").Select
objMSWord.Selection.TypeText Adodc1.Recordset.Fields("Price")
objMSWord.ActiveDocument.Bookmarks("Salesman").Select
objMSWord.Selection.TypeText Adodc1.Recordset.Fields("Salesman")
objMSWord.ActiveDocument.Bookmarks("Scope").Select
objMSWord.Selection.TypeText Adodc1.Recordset.Fields("Scope")
objMSWord.ActiveDocument.Bookmarks("State").Select
objMSWord.Selection.TypeText Adodc1.Recordset.Fields("State")
objMSWord.ActiveDocument.Bookmarks("Title").Select
objMSWord.Selection.TypeText Adodc1.Recordset.Fields("Title")
objMSWord.ActiveDocument.Bookmarks("Zip").Select
objMSWord.Selection.TypeText Adodc1.Recordset.Fields("Zip")
objMSWord.ActiveDocument.Bookmarks("Job").Select
objMSWord.Selection.TypeText Adodc1.Recordset.Fields("Job #")
objMSWord.Visible = True
Splash4.Hide
MsgBox "The export is finished. You can now access the Proposal"
ASKER
Let me try that and get back to you
ASKER
There error happens on the line in bold
On Error GoTo ConnErrHandler1
Set objMSWord = CreateObject("Word.Application")
On Error GoTo ConnErrHandler2
Set myDOc = objMSWord.Documents.Open("xxxxxxx", ReadOnly:=False)
On Error GoTo ConnErrHandler3
objMSWord.ActiveWindow.View = wdPrintView
So obviously it cannot load the document.
Can you load it interactively using that URL? If yes, consider showing the Word application window.
Can you load it interactively using that URL? If yes, consider showing the Word application window.
ASKER
Yes I can load it interactively from the URL. What do you mean show the Word application window?
Do you mean like this? objMSWord.ActiveWindow.View = wdNormalView
Do you mean like this? objMSWord.ActiveWindow.View = wdNormalView
objMSWord.Visible = True
ASKER
When I put it here, the Word program comes up but the document does not appear. Then the error comes up after that.
On Error GoTo ConnErrHandler1
Set objMSWord = CreateObject("Word.Application")
objMSWord.Visible = True
On Error GoTo ConnErrHandler2
Set myDOc = objMSWord.Documents.Open("xxxxx", ReadOnly:=False)
On Error GoTo ConnErrHandler3
objMSWord.ActiveWindow.View = wdNormalView
Try to run a Office repair installation.
ASKER
That didn't help. I did notice that all the computers at work have two installations. Office 365 apps and also Office 2002. Both seem to work fine on the machines tho.
I have Microsoft Word 15.0 Object Library referenced in my project. Is it possible that I need to add10.0 to that?
I have Microsoft Word 15.0 Object Library referenced in my project. Is it possible that I need to add10.0 to that?
Hi!
What can be different from your home PC and your office PC?
- You compile on your home PC which is 64 bits while your office PC is 32 bits
- Check the versions of .NET framework. You may compile using a higher version of .Net runtime.
Check the other possibilities here: https://software-solutions-online.com/automation-error-vba/ under "Common Causes and Things to Check"
What can be different from your home PC and your office PC?
- You compile on your home PC which is 64 bits while your office PC is 32 bits
- Check the versions of .NET framework. You may compile using a higher version of .Net runtime.
Check the other possibilities here: https://software-solutions-online.com/automation-error-vba/ under "Common Causes and Things to Check"
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
My guess is that its possible to add the reference to MS Word Objects library 10.0. Its worth a try.
Make sure all the references are the same on both PCs.
Get rid of MS Word Objects library 15.0. Because it will compile using the 15.0 version eventually.
Make sure all the references are the same on both PCs.
Get rid of MS Word Objects library 15.0. Because it will compile using the 15.0 version eventually.
ASKER
The 15 point out automatically disappeared. I guess what I'm trying to find out is can I get the 10.0 on there even though it's not installed on my home machine. It looks like I can't but I'm wondering if there is a way to get those files online
ASKER
The 15.0 automatically disappeared. I guess what I'm trying to find out is can I get the 10.0 on there even though it's not installed on my home machine. It looks like I can't but I'm wondering if there is a way to get those files online
Better be patient and get the file from your work machine. You may download a rotten DLL.
ASKER
what would the file look like or be called?
VB6 is not very friendly for finding the librairy files. If you click the reference from the references window, the beginning of the path is displayed. Start from here. You will need to register the DLL with regsrv.
The full path may be displayed when you rebuild the project. I don't recall. VB6 is very old.
Otherwise your only option is to get an Office 2002 CD and install it on your home PC.
The full path may be displayed when you rebuild the project. I don't recall. VB6 is very old.
Otherwise your only option is to get an Office 2002 CD and install it on your home PC.
After a little research, the file you are looking for is called MSO.DLL
ASKER
Thank you
ASKER
Its not MSO.DLL. Its MSWORD.OLB
Okay, Mybad.
Please accept your comment as the answer.
Please accept your comment as the answer.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Cause doing all in a single method means we don't know what failed. So loading Word, loading the document and manipulating it should be separated into three methods, each having an error handler.