I'm trying to check for the existence of specific parameters in a part and if it does not exist then I want to skip a small section of my code. This is my current code that works as desired:
Dim partDoc As PartDocument
Set partDoc = CATIA.ActiveDocument
Dim ParamV As Parameter
Set ParamV = partDoc.Part.Parameters.Item("ParName")
Dostuffwith ParamV
Now I want to add a check before executing the last 2 lines of code, it would become something like this:
Dim partDoc As PartDocument
Set partDoc = CATIA.ActiveDocument
Dim ParamV As Parameter
If partDoc.Part.Parameters.Item("ParName") Exists
then
Set ParamV = partDoc.Part.Parameters.Item("ParName")
Dostuffwith ParamV
End If
I tried using
On Error goto label1
Set ParamV = partDoc.Part.Parameters.Item("ParName")
Dostuffwith ParamV
label1
But this is impossible because On Error needs to end with a Resume or Resume Next. I couldn't find a way to make it Resume after "Dostuffwith ParamV", it will always Resume at the line of code that prompted the error in the first place.
I also tried
If not partDoc.Part.Parameters.Item("ParName") is nothing
Then
Set ParamV = partDoc.Part.Parameters.Item("ParName")
Dostuffwith ParamV
End If
But this also gives an error because parameter ParName just doesn't exist.
I don't know what else I can try, please help.