Shape selection of more than one layer?

Started by kedas, August 21, 2014, 10:21:44 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

kedas

Hi,

It seems like an easy thing to do but I can't seem to find how.
I want a selection object with the shapes of a few layers.
So I could have vsoSelection1 and vsoSelection2  but how to put them in one vsoSelection object (to use the .Export to file function)


Set vsoSelection1 = ActivePage.CreateSelection(visSelTypeByLayer, visSelModeSkipSuper, vsoLayer1)

Set vsoSelection2 = ActivePage.CreateSelection(visSelTypeByLayer, visSelModeSkipSuper, vsoLayer2)

vsoSelection= ?

Visio Guy

Hi Kedas,

You have to unify the selections, manually, unfortunately. Something like this (from memory, some constants might be slightly different)

Dim sel1 as Visio.Selection, sel2 as Visio.Selection
'//...set up sel1 and sel2

'// Unify sel1 and sel2 in sel3:
Dim sel3 as Visio.Selection
Set sel3 = sel1.ContainingPage.CreateSelection(Visio.VisSelectionTypes.visEmpty)
Dim shp as Visio.Shape
For Each shp in sel1
    Call sel3.Select(shp, Visio.VisSelectArgs.visSelect)
Next shp
For Each shp in sel2
    Call sel3.Select(shp, Visio.VisSelectArgs.visSelect)
Next shp

'// sel3 now contains shapes from both sel1 and sel2
For articles, tips and free content, see the Visio Guy Website at http://www.visguy.com
Get my Visio Book! Using Microsoft Visio 2010

kedas

Thanks for the info


Function UnifySelections(Selections1 As Visio.Selection, Selections2 As Visio.Selection, Optional Selections3 As Visio.Selection = Nothing, Optional Selections4 As Visio.Selection = Nothing) As Visio.Selection

    Dim sel As Visio.Selection
    Dim vsoshp As Visio.Shape
    Set sel = ActivePage.CreateSelection(Visio.VisSelectionTypes.visSelTypeEmpty)
    For Each vsoshp In Selections1
        sel.Select vsoshp, Visio.VisSelectArgs.visSelect
    Next vsoshp
    For Each vsoshp In Selections2
        sel.Select vsoshp, Visio.VisSelectArgs.visSelect
    Next vsoshp
    If Not (Selections3 Is Nothing) Then
        For Each vsoshp In Selections3
            sel.Select vsoshp, Visio.VisSelectArgs.visSelect
        Next vsoshp
    End If
    If Not (Selections4 Is Nothing) Then
        For Each vsoshp In Selections4
            sel.Select vsoshp, Visio.VisSelectArgs.visSelect
        Next vsoshp
    End If
    Set UnifySelections = sel

End Function