Pass parameters to a VBA macro from an iLogic Rule

<?xml encoding=”UTF-8″>By Adam Nagy

Though RunMacro functionality is only listed in the iLogic function browser tree without the argument parameters: RunMacro(projectName, moduleName, macroName) 

RunMacroWithArgs

… it seems it can be used this way too: RunMacro(projectName, moduleName, macroName, argument1, argument2, etc) – in which case argument1argument2, etc. will passed as the VBA macro‘s input parameters in the same order.

It was discussed in this forum thread: 
https://forums.autodesk.com/t5/inventor-general-discussion/ilogic/td-p/2611136

So you could have an iLogic Rule calling a VBA macro with parameters like this: 

InventorVb.RunMacro(
"ApplicationProject", ' projectName
"Module1",               ' moduleName
"MyMacro",              ' macroName
"Hello again!")         ' the first argument we pass to the VBA macro

The above would call a VBA macro from e.g. ApplicationProject >> Module1 

Sub MyMacro(argument1 As String)
Call MsgBox(argument1) ' >> would pop up with "Hello again!"
End Sub

Comments

Leave a Reply

Discover more from Autodesk Developer Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading