How can you execute an inventor sub from excel

How can you execute an inventor sub from excel

Anonymous
Not applicable
343 Views
1 Reply
Message 1 of 2

How can you execute an inventor sub from excel

Anonymous
Not applicable
I have a excel macro to open inventor for a list of files in excell
*******
Sub Main()
Dim oInvApp As Inventor.Application
'Launch Inventor
Set oInvApp = CreateObject("Inventor.Application")
oInvApp.Visible = True
oInvApp.SilentOperation = True
'Set Startup options.
oInvApp.GeneralOptions.ShowStartupDialog = False
Dim oDoc As Inventor.DrawingDocument
counter = Application.ActiveWorkbook.ActiveSheet.Cells(1, 7).Value

For i = 1 To counter
nPath = Application.ActiveWorkbook.ActiveSheet.Cells(i + 1, 6).Value
m = Application.ActiveWorkbook.ActiveSheet.Cells(i + 1, 2).Value
oName = "C:\_Vault Workspace\Designs\" & nPath & "\" & m & ".idw"
Set oDoc = oInvApp.Documents.Open(oName)
fNAME = oDoc.FullFileName
'fNAME = Left(fNAME, Len(fNAME) - 3) & "dwg"
Dim iPath As Integer
Dim sPath As String
iPath = InStrRev(fNAME, "\")
sPath = Left(fNAME, iPath)
Next i
'Call createDWG(oDoc.Parent, dwgAddIn, fNAME, sPath)
'oDoc.Close SaveChanges = False
'oInvApp.Quit
Set oInvApp = Nothing
End Sub
*******

How do i run a inventor subroutine? i tried putting Call MyMacro() but it didnt work

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

Anonymous
Not applicable
There is a collection representing the VBA projects in the Inventor:

oInvApp.VBAProjects(index1).InventorVBAComponents(index2).InventorVBAMembers(index3).Execute ''''''''''''''''''''

VBAProjects - collection containing all open VBA projects '''''''''''''''''
InventorVBAComponents - collection containing all modules in a VBA project '''''''''''''''
InventorVBAMembers - collection with all subs in a module '''''''''''''''

index1 - represents the project containing the desired sub (I'm not sure if you can use a string equal to project name) ''''''''''''''
index2 - represents the module containing the sub, you can use a string equal to the module name ''''''''''''''
index3 - represents the sub, you can use a strnig equal to the sub name. ''''''''''''''''''' Edited by: danmoller on Oct 2, 2008 4:42 PM
0 Likes