ActiveWindow.Selection.Count=0 when only a group member shape is selected

Started by Hey Ken, July 18, 2018, 07:15:47 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Hey Ken

   Okay, here's another one:

1.  Take two shapes and group them.
2.  Select the group, and ActiveWindow.Selection.Count=1.
3.  But select only one of the shapes inside the group, and (as the title implies) ActiveWindow.Selection.Count=0, even though a shape is surely selected.

   What am I missing?  How can you know when a sub-shape alone is selected?  How can I access its shapesheet?

   - Ken


Ken V. Krawchuk
Author
No Dogs on Mars - A Starship Story
http://astarshipstory.com

Yacine

You forgot to tell Visio to select sub-shapes: https://msdn.microsoft.com/en-us/VBA/Visio-VBA/articles/selection-iterationmode-property-visio

    Set sel = ActiveWindow.Selection
    sel.IterationMode = visSelModeSkipSuper
    for each shp in sel ...
Yacine

Hey Ken

Yacine:

   Huh!  Never heard of the option before.  Pretty cool.  And it did the trick!  Ya learn something new every day.

   (And pardon the quibble, but logically speaking I could not "forget" something I never knew...  ;- )

   Of course I had to play with it, and noted that it refuses to allow sel.IterationMode = visSelModeSkipSuper + visSelModeOnlySuper.  Ditto for SkipSub and OnlySub.  "Invalid parameter," it tells me.  Indeed.

   Regardless, it's now another arrow in my increasingly-overcrowded Visio quiver.  Thanks muchly!

   - Ken

Ken V. Krawchuk
Author
No Dogs on Mars - A Starship Story
http://astarshipstory.com