Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
JBEDsol
292 Views, 2 Replies

Do all custom iProperties require a string output?

I'm trying to set up a code where I can update an iProperty based on inputs.  I modified the example code to update iProperties.  The sub would be used with texts, bools, and numbers.  I set the input as a variant but get errors if I pass anything other than a variant or string.  What's the rules on iProps?

Public Sub CalliProp()

Dim docCurr As Document
Set docCurr = ThisApplication.ActiveDocument

Dim dblTest As Double
dblTest = 3.22222

Call UpdateCustomiProp(docCurr, "Woohah", dblTest)

End Sub
Public Sub UpdateCustomiProp(docDoc As Document, strPropTitle As String, varValue As Variant)
       
    ' Get the custom property set.
    Dim psCustom As PropertySet
    Set psCustom = docDoc.PropertySets.Item("Inventor User Defined Properties")
        
    Dim propCurrent As Property
    Set propCurrent = psCustom.Item(strPropTitle)
    
    If Err.Number <> 0 Then
        ' Failed to get the property, which means it doesn't exist
        ' so we'll create it.
        Call psCustom.Add(varValue, strPropTitle)
    Else
        ' Got the property so update the value.
        propCurrent.Value = varValue
    End If

End Sub