vba - Dynamic labelling of shapes -


i creating shapes within for-loop , want each shape having different name. therefore, shape in set shape = ... in each iteration should have shape replaced dynamic variable.

if place shapes via set shape = w.shapes.addshape(msoshaperectangle, 10,10,10,10) how can have shape (the name of shape) dynamic e.g. set cells(1 + i, 1) = w.shapes.addshape(msoshaperectangle, 10,10,10,10) ... each shape has different name. tried shape.name = not seem have same effect setting name while creating shape.

i assign name each shape create within loop: shape.name = cells(ganttstartrow + i, 1) & cells(ganttstartrow + i, 2)

i set connector via set conn = w.shapes.addconnector(msoconnectorelbow, 1, 1, 1, 1) conn.connectorformat.beginconnect d, 1 conn.connectorformat.endconnect wp, 1 ... receive "type mismatch" error.

assuming ws worksheet working with:

dim s shape, integer = 1 5     set s = ws.shapes.addshape(msoshaperectangle, 50 + * 120, 200, 100, 100)     s.name = "myshapename" & next 

you can later access shapes name:

for = 1 5     set s = ws.shapes("myshapename" & i)     s.fill.backcolor.rgb = rgb(0, 255 - * 50, * 50)     s.backgroundstyle = next 

however, alternative loop on shapes:

for each s in ws.shapes     dim integer     if left(s.name, 1, 11) = "myshapename"         = val(mid(s.name, 12))         s.top = s.top + * 4     end if next s 

Comments

Popular posts from this blog

html - How to set bootstrap input responsive width? -

javascript - Highchart x and y axes data from json -

javascript - Get js console.log as python variable in QWebView pyqt -