07-22-2024
04:57 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
07-22-2024
04:57 AM
good monring,
here is the code i use to check if a parameter exists, it uses a loop to check a name. i've found it works well and is robust.
'set ref to active doc Dim oActiveDoc As Document = ThisApplication.ActiveDocument 'set ref to user parameters Dim oUserParams As UserParameters = oActiveDoc.ComponentDefinition.Parameters.UserParameters 'set ref to user parameter Dim oUserParam As UserParameter 'set ref to counter Dim i As Integer i = 1 'set up param search name Dim oParamSearchName As String = "TestName" For Each oUserParam In oUserParams If oUserParam.Name = oParamSearchName Then Call MsgBox("User Paramater - " & oParamSearchName & " - Exist.", vbOKOnly, "Check User Paramaters") Exit For End If 'if count = i then param doesn't exisit trip message box If i = oUserParams.Count Then Call MsgBox("User Paramater - " & oParamSearchName & " - Does NOT Exist.", vbOKOnly, "Check User Paramaters") i = i + 1 Next