Code:
Dim invApp As Inventor.Application'Open the Inventor Application
On Error Resume Next
Set invApp = GetObject(, "Inventor.Application") '<-- Get the Inventor Application if it's already open
If Err Then
Set invApp = CreateObject("Inventor.Application") '<-- Create the Inventor Application if it's NOT open
invApp.Visible = True
Set invApp = GetObject(, "Inventor.Application") '<-- Activate the Inventor Application after it's open
End If
'Close any open documents
If invApp.Documents.Count > 0 Then
invApp.Documents.CloseAll
End If
Dim oDesignProjectMgr As DesignProjectManager
Set oDesignProjectMgr = invApp.DesignProjectManager
' Get the project to activate
' This assumes that "C:\Temp\MyProject.ipj" exists.
Dim oProject As DesignProject
Set oProject = oDesignProjectMgr.DesignProjects.ItemByName("C:\temp\MyProject.ipj")
' Activate the project
oProject.Activate
Dim oAssDoc as AssemblyDocument
Set oAssDoc = invApp.Documents.Open("FullDocumentName", True)