Author Topic: Summing Shape Data Category from each shape on a page  (Read 100 times)

0 Members and 2 Guests are viewing this topic.

calkevicius

  • Newbie
  • *
  • Posts: 3
Summing Shape Data Category from each shape on a page
« on: August 14, 2020, 05:38:11 PM »
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.  :)

vojo

  • Hero Member
  • *****
  • Posts: 1513
Re: Summing Shape Data Category from each shape on a page
« Reply #1 on: August 14, 2020, 06:45:23 PM »
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.

calkevicius

  • Newbie
  • *
  • Posts: 3
Re: Summing Shape Data Category from each shape on a page
« Reply #2 on: August 14, 2020, 07:46:19 PM »
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