Summing Shape Data Category from each shape on a page

Started by calkevicius, August 14, 2020, 10:38:11 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.


Say I have 5 shapes on a page and they all have a shape data category "Weight" which is set as a Number. Is it possible to create another shape on the page that will display the sum of all 5 shape weights? I'm sure there's a thread on here for such a simple request but I'm new here and I'm pretty new to VBA for Visio.  :)


2 cases

Case 1  shapes are static:
- all shapes are place on the page 1 time at beginning
- no new shape to include / none of the 5 shapes deleted
- thus the shape ID are well known

Then can do it via shapesheet functions
sum = sheet.1!prop.weight + sheet.2!prop.weight + etc

Case 2  shapes are dymanic
- different number of shapes place....3,4,5,6,7,etc shapes

then can do it via VBA

The issue is that a given shape is unaware of other shapes on the page
(no discovery of shapes, no communication of shapes, etc)
So need VBA.

Even a clumsy approach of each shape placing its weight in page!prop.weight1 or page!prop.weight2 has
limitations (finite max shapes, preload 0 in page props , need to figure out to 0 a weight out if shape deleted).

you should look at Junes calculation shapes for ideas.


Thank you for the reply. Option 2 is the way to go as I want it to work no matter which shapes are placed on the page. I'll check June's calculation sheet. You know any tutorials for VBA syntax? lol