I imagine you recorded a macro to get this result?
Instead, you should use a "For Each" function that will go through all the dimensions of the part, an example (which will retrieve the values of all the dimensions for all the configurations), see this section of the API help:
I didn't use a for each function but when creating my rating I gave it the name I wanted to passge.
Below is the modified code that works.
Dim myDisplayDim As Object Set myDisplayDim = swmodel. AddDimension2(-0.15, height / 2, 0) Dim myDimension As Object Set myDimension = swmodel. Parameter("H@Esquisse2") Set swSelMgr = swmodel. SelectionManager Set swDispDim = swSelMgr.GetSelectedObject5(1) Dim swDim As SldWorks.Dimension Set swDim = swDispDim.GetDimension Dim nom_cote As String