Message 1 of 12
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I am attempting to load inventor with VBA. While the program will start and load files it will not load all of my addins. This is specific to when starting it with VBA. If I do it manually by clicking on the icon, it loads everything normally. While I can simply let everyone know that they need to load Inventor manually, in order to avoid errors (one our save functions includes a sequential number generator on save, so it becomes impossible to save without the addins) I would like to know what is causing the issue and resolve it if possible.
'Opens an existing file or creates a new one. Returns the file reference
'Pass it the template you wish to use for a new document. Acceptable template files listed below
' Assembly (Imperial).iam, ASTM Angle.ipt, ASTM Channel.ipt, ASTM Miscellaneous Channel.ipt, ASTM Rectangular Tube.ipt, ASTM Wide Flange Beam.ipt, _
' Copper Bar Part (Imperial).ipt, Grating Material Template (Imperial).ipt, Non-Metallic Sheet Outsourced.ipt, Part - Other (Imperial).ipt, _
' Roll Fromed Coil.ipt, Sheet Metal Part (Imperial).ipt, Weldment (Imperial).iam
'\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
Public Function OpenInventorFile(FileName As String, NewFile As Boolean) As Variant
On Error Resume Next
Dim InventorObjects(1) As Object
Dim Doc As Object
Dim Inventor As Object
Dim iLogic As Object
Dim Location As String
Dim TemplateName As String
Dim DocType As DocumentTypeEnum
'Get open instance of inventor or open one if nothing is found
Set Inventor = GetObject(, "Inventor.Application")
If Err Then
Err.Clear
Set Inventor = CreateObject("Inventor.Application")
End If
Inventor.Visible = True
'If this is an old file simply open it
If NewFile = False Then
Set Doc = Inventor.Documents.Open(FileName)
'If it is a new file then determine the template and document and add a new file
Else
Location = "C:\Work\Designs\Templates\2013\Inventor Templates\Imperial\"
TemplateName = Location & FileName
If FileName = "Assembly (Imperial).iam" Or FileName = "Weldment (Imperial).iam" Then
DocType = kAssemblyDocumentObject
Else
DocType = kPartDocumentObject
End If
Set Doc = Inventor.Documents.Add(DocType, TemplateName, True)
End If
Set InventorObjects(0) = Inventor
Set InventorObjects(1) = Doc
OpenInventorFile = InventorObjects
End Function
'\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
Solved! Go to Solution.