Greeting Everyone,

I have a CATIA V5 file and i want to make a GUI using VBA.
I had one semester of VBA but it was a lifetime ago.

So I recorded a macro in CATVBA that allows the user to select a specific CATPart in an assembly, I'm going to insert it in a GUI via VBA editor to make a Slider "graphical menu" to speed up process of going up and down the CATIA spec tree and to make it attractive to management

I'm trying to alter a user selected parameter of a selected CATPart in an assembly via CADSelection. I've recorded the macro several times and tried to incorporate oSelection in several places and tweaked around with this for a while now, but i can't seem to finish this.

Am i declaring oSelection in the incorrect place, or am i missing something else?

My CATIA spec tree is:







All of the above "Part_Teste" have 3 parameters one of them is called "Comprimento"

How do I change make sure that the macro alters the selected CATPArt's parameter instead of ("Part_Teste_3.CATPart")?

The macro that I have so far is:


Sub CATMain()

Set oProductDoc = CATIA.ActiveDocument

Set oProd = oProductDoc.Product

Set oDocs = CATIA.Documents

Set oSelection = CATIA.ActiveDocument.Selection

If oSelection.Count < 1 then

    MsgBox "Pick some components using cad selection.","No components were selected"


    Set oPartDoc = oDocs.Item("Part_Teste_3.CATPart")

    Set oPart = oPartDoc.Part

    Set oParam = oPart.Parameters

    Set oLength = oParam.Item("Comprimento")

    oLength.Value = 50.000000

End If



End Sub