Visio Guy

Visio Discussions => Programming & Code => Topic started by: diwakaramit on October 16, 2022, 07:35:56 AM

Title: Counting no of items for each Layer
Post by: diwakaramit on October 16, 2022, 07:35:56 AM
Hello -

I am trying to create a Macro that can generate a list of layer name and no of items associated with each layer. For example, in the attached visio sample has one page "Page-1" but in reality i could have 100 pages.
In the sample when i open the layer properties i see one layer "4-014A" that has zero shapes/items associated. I will have to delete this layers. But i will have to do this manual task on 100 pages, instead I am looking to generate a list that will give me all the layer name and associated page that have zero shapes/items associated with that layer. Is it possible to do as a macro? i tried using "Layer.Shapes.Count" but it looks like this is not in VBA library. So what is the command prompt i could use?

P.S : i know the layers are not aligned on the page currently but this is just a sample so the actual visio page actually looks different

Thank you very much

Title: Re: Counting no of items for each Layer
Post by: wapperdude on October 16, 2022, 03:16:20 PM
See the following.  In 1st link, Look at Nikolay's suggestuion. 
In second link, A more detailed code example.  At the end, there's discussion re using local vs universal naming.

http://visguy.com/vgforum/index.php?topic=8920.msg39174#msg39174 (http://visguy.com/vgforum/index.php?topic=8920.msg39174#msg39174)
https://stackoverflow.com/questions/72550038/getting-the-number-of-shapes-with-in-a-layer-on-visio-using-vba (https://stackoverflow.com/questions/72550038/getting-the-number-of-shapes-with-in-a-layer-on-visio-using-vba)
Title: Re: Counting no of items for each Layer
Post by: diwakaramit on October 17, 2022, 04:36:59 AM
Thank you so much.  This was really helpful