CreateSelection from multiple layers?

Started by orsmo, April 18, 2023, 03:52:21 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

orsmo

I've created a document with multiple layers and some VBA that turns those layers on and off to cobble together a diagram for a given situation.  All that works great.  Now I've just got one more thing to do.  I want to create a button that, when pressed, selects and exports that diagram.  There are other layers visible on the same page that are not to be included in the diagram.  I do have a list of the visible layer names that are meant to be a part of the diagram though, accumulated as layers were made visible.  Once I've managed to sort out the selection, Selection.Export looks like it will let me do the actual task.

Page.CreateSelection at first seems a brilliant way to go about this, but appears to create a new selection object populated with just the shapes from the one layer called out in its arguments.  It doesn't appear to be additive.  That is to say that calling it again creates a new selection object with only the newly specified layer's contents.  I don't see a way to combine two selection objects in any documentation I've been able to find, but maybe someone here knows of a way?

So how do I build up a selection from multiple layers?




Surrogate

#1
Quote from: orsmo on April 18, 2023, 03:52:21 PMSo how do I build up a selection from multiple layers?
I write this code via macro-recorder
Dim vsoSelection1 As Visio.Selection
Set vsoSelection1 = Application.ActiveWindow.Page.CreateSelection(visSelTypeByLayer, visSelModeSkipSuper, "a;c")
Application.ActiveWindow.Selection = vsoSelection1

How select multiple layers via user interface

orsmo

AHA!  So it looks like a semi-colon separated list of layer names will allow multiple layers to be passed to Page.CreateSelection.  Awesome catch!  Thank you.