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

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