CreateObject Error - Inventor and VB6

CreateObject Error - Inventor and VB6

Anonymous
Not applicable
430 Views
1 Reply
Message 1 of 2

CreateObject Error - Inventor and VB6

Anonymous
Not applicable
Hi,

I have created a class that uses CreateObject /GetObject to open an
application. Every time the class creates a new instance of the application,
when the class exits it returns an Application Error The error states the
memory location and " "The memory could not be "read".

When I place a break point in the code the error does not occur. So I placed
an OK Only message box in the Terminate event this also prevented the error.
I also used a loop and this worked but not a good solution.

I am trying to find a solution that does not require operator intervention
has anyone any ideas.



'GetObject("", "Inventor.Application") always creates a new Instance

The basic code:

Set oApp = GetObject("", "Inventor.Application")

Set oDoc = oApp.Documents.Open("C:\BradTest.ipt")

oApp.Visible = True


Dim oPartDef As PartComponentDefinition

Set oPartDef = oDoc.ComponentDefinition

Code to make changes

oDoc.Save

oDoc.Close

oApp.Visible = False





Thanks
0 Likes
431 Views
1 Reply
Reply (1)
Message 2 of 2

paulschuepbach
Contributor
Contributor
Alvin,
here's a sample to create/get a object from Inventor for Excel:

' at the beginning of Form_Load() Sub:
On Error Resume Next

Set oEx = GetObject(, "Excel.Application")

' Error, if Excel is not already running, then Create Excel-object
If Err.Number <> 0 Then
Set oEx = CreateObject("Excel.Application")
End If

Err.Clear

oEx.Visible = True


I think this will work the other way around (from any application to Inventor) too.

The other thing: at the end of your code, you just set yout Inventor-object to invisible - the object
is still alive. Do the following at the end:

Set oApp = Nothing

The object ist terminated. Otherwise, Inventor ist just invisible, but if you watch the
Task-Manager, Inventor.exe is still alive and this will crate a error (for each 'alive'
Inventor object.
Note the following: If your application crashes somewhere in the middle of it's code, the
Inventor object will stay alive and you will have to kill it via TaskManager.

Hope this helps,

Best, Paul
0 Likes