Visio Guy

Visio Discussions => Programming & Code => Topic started by: Hey Ken on July 18, 2018, 07:15:47 PM

Title: ActiveWindow.Selection.Count=0 when only a group member shape is selected
Post by: Hey Ken on July 18, 2018, 07:15:47 PM
   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


Title: Re: ActiveWindow.Selection.Count=0 when only a group member shape is selected
Post by: Yacine on July 18, 2018, 07:31:41 PM
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 ...
Title: Re: ActiveWindow.Selection.Count=0 when only a group member shape is selected
Post by: Hey Ken on July 19, 2018, 12:54:26 PM
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