Part Document Name Change Problem

Hi everyone,

I wrote a macro with catia and when I press the button I want it to transfer the value in my variable named dim code1 as string to the part number value of the active document is PART DOCUMENT part.

 

 

Dim activedoc as object

Set activedoc = catia.activedocument

Dim code1 as string

Code1 = "A123456"

If typeof activedoc is pardocument then

    Dim prt as part

    Set prt= activedoc.prt

  'Here not working 

    'prt.name=code1

    'prt.Part.partnumber=code1

    'Prt.part.name=code1

Else

Others code...

End if

 

Why doesn't the above code block write the data of my variable to the partnumber section if it is the active document part?