
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi
How can I pass arguments from iLogic to a vb macro?
I have tried the approach which we normally use when passing arguments between iLogic rules. But I am missing something in the process of passing the arguments to the VBmacro. Below is a simplified version of the problem. I want to control which sheet in the excel workbook opens...
Here is what I have:
iLogic code
Dim Value_1 As Integer Value_1 = 1 Dim map As Inventor.NameValueMap = ThisApplication.TransientObjects.CreateNameValueMap() map.Add("Arg", Value_1) InventorVb.RunMacro("DocumentProject", "Access_excel", "openexcel", map)
Vb macro
Sub openexcel()
Dim oApp As Inventor.Application
Dim oOleRef As ReferencedOLEFileDescriptor
Dim oWB As Excel.Workbook
Dim oSheet As Excel.WorkSheet
Dim oChart As Excel.Chart
Set oApp = ThisApplication
Set oOleRef = oApp.ActiveDocument.ReferencedOLEFileDescriptors.Item(1)
Call oOleRef.Activate(kEditOpenOLEVerb, oWB)
Value_1 = RuleArguments("Arg")
If RuleArguments.Exists("Arg") Then
Set oSheet = oWB.Sheets("Sheet1")
oSheet.Activate
MsgBox (oSheet.Name)
Else
Set oChart = oWB.Charts("Chart1")
oChart.Activate
MsgBox (oChart.Name)
End If
End Sub
A workaround is to make two macros in VB and call them individually. But passing arguments to VB could also come in handy for other codes that we are working with.
Solved! Go to Solution.