22 | 02 | 2017

Connect to Inventor using Late Binding

The code below connect to Inventor using late binding. 

 Public Sub connectInv22()


Dim objBlockRef As Object
Dim oApp As Object

On Error GoTo errorhandler

'attempt to get last version of Inventor opened
oApp = GetObject(, "Inventor.Application")
If Err.Number <> 0 Then
MsgBox("Inventor application is not open")
Err.Clear()
Exit Sub

'attempt to create instantiation of last version of Inventor opened
oApp = CreateObject("Inventor.Application")
'no AutoCAD is available
If Err.Number <> 0 Then
MsgBox("Cannot start Inventor... sorry!", vbExclamation, "Error starting Inventor")
End If
End If
AppActivate("Inventor")
oApp.Visible = True
Dim oDoc As Object
oDoc = oApp.ActiveDocument

Msgbox oDoc.Name

errorhandler:

MsgBox(Err.Description)
End Sub
Login

Sign up now and upload your code to the website.

Help us to continue.....
Statistics
Articles View Hits
2174952
Latest Articles