Message 1 of 7
Creating multivalue parameters in VBA
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Ok, so I'm trying to shift some of my stuff over from iLogic to VBA and I'm having some issues with multivalue parameter creation. The parameter.ExpressionList.SetExpressionList function is just endlessly crashing the program. No error messages, no warnings, even the debugger won't do anything. Just boom, program gone, every single time.
I know that my function is returning a new parameter so I'm a little unsure what is going on.
Thank you
Dim oParam As UserParameter
Dim valList(4) As String
valList(0) = "None"
valList(1) = "Side A"
valList(2) = "Side C"
valList(3) = "Side A & C"
Set oParam = Assembly_Functions.ParaCreation("LWSplits", "None", "Text")
Call oParam.ExpressionList.SetExpressionList(valList)
'The ParaCreation function checks if a parameter exists and if it does not creates it with the defined type and starting value.
'The types defined for it are "Number", "Boolean", and "Text"
Function ParaCreation(sName As String, StartValue As String, oType As String) As UserParameter
'Declaring document variables
Dim oMyAssembly As AssemblyDocument
Set oMyAssembly = ThisApplication.ActiveDocument
Dim oMyParameter As UserParameters
Set oMyParameter = oMyAssembly.ComponentDefinition.Parameters.UserParameters
Dim oCompDef As AssemblyComponentDefinition
Set oCompDef = oMyAssembly.ComponentDefinition
Dim oParam As UserParameter
'Create boolean for checking existence of parameter
Dim blTag As Boolean
blTag = False
'Check through parameters to make sure parameter doesn't exist
For i = 1 To oCompDef.Parameters.Count
If oCompDef.Parameters(i).name = sName Then
blTag = True
Set oCompDef.Parameters(i).Value = StartValue
Set oParam = oCompDef.Parameters(i)
Exit For
End If
Next
'Create parameter if it doesn't exist
If blTag = False Then
If oType = "Text" Then Set oParam = oMyParameter.AddByValue(sName, StartValue, UnitsTypeEnum.kTextUnits)
If oType = "Number" Then Set oParam = oMyParameter.AddByExpression(sName, StartValue, "in")
If oType = "Boolean" Then
Dim boolValue As Boolean
If StartValue = "True" Then
boolValue = True
Else
boolValue = False
End If
Set oParam = oMyParameter.AddByValue(sName, boolValue, "Boolean")
End If
End If
Set ParaCreation = oParam
End Function