Help With Calculating Shape Data

Started by minnise, October 19, 2020, 01:44:17 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

minnise

I hope I can explain what I'm looking for.  I need help with a ShapeSheet formula that would calculate the shape data value in multiple shapes.  I have multiple shapes with the same shape data fields that are all on the same layer.  I want to be able to calculate the specific shape data field of all of these shapes on a separate shapes shapesheet.

Shapes in Layer 2:
Shape "1" (shape data field value of 2)
Shape "2" (shape data field value of 2)
Shape "3" (shape data field value of 2)

Shape "Total" (shape data field 6)

wapperdude

You can  do something as attached.  The parallelogram is the "collecting" shape.
The layer in question is hard coded on the line beginning "Set vsoSelection1 ="

The program uses the layer name to select all appropriate shapes on that layer.  It then looks at each shape and pulls desired info.  There is no error correcting.  So if a shape doesn't have desired cell, it will bomb.  Easy enough to correct.


Sub Macro1()
    Dim vsoSelection1 As Visio.Selection
    Dim shp As Visio.Shape
    Dim Cnt As Integer
   
    Dim vShpCnt As Visio.Shape
   
    Set vShpCnt = ActiveWindow.Selection(1)
    vShpCnt.Cells("User.NumShps").Formula = "0"
    vShpCnt.Cells("User.TotSides").Formula = "0"
   
    Cnt = 0
    Set vsoSelection1 = ActiveWindow.Page.CreateSelection(visSelTypeByLayer, visSelModeSkipSuper, "Triple")
    ActiveWindow.Selection = vsoSelection1
   
    For Each shp In vsoSelection1
        Cnt = Cnt + 1
        vShpCnt.Cells("User.NumShps").Formula = Cnt
        vShpCnt.Cells("User.TotSides").Formula = vShpCnt.Cells("User.TotSides").Result("") + shp.Cells("User.Sides").Result("")
        Debug.Print Cnt, shp.Cells("User.Sides").Result(visNone)
    Next
        Debug.Print ""
        Debug.Print vShpCnt.Cells("User.NumShps").Result(visNone), vShpCnt.Cells("User.TotSides").Result(visNone)
End Sub
Visio 2019 Pro