Window.Select-Methode (Visio)

Wählt ein Objekt aus oder hebt die Auswahl auf.

Syntax

Ausdruck. Select (SheetObject, SelectAction)

Ausdruck Eine Variable, die ein Window-Objekt darstellt.

Parameter

Name Erforderlich/Optional Datentyp Beschreibung
SheetObject Erforderlich [IVSHAPE] Ein Ausdruck, der ein Shape-Objekt zurückgibt, das ausgewählt oder dessen Auswahl aufgehoben werden soll.
SelectAction Erforderlich Integer Die durchzuführende Art von Auswahlaktion.

Rückgabewert

Nichts

Bemerkungen

Bei Verwendung mit dem Window-Objekt wirkt sich die Select-Methode auf die Auswahl im Microsoft Visio-Fenster aus. Das Selection-Objekt ist jedoch unabhängig von der Auswahl im Fenster. Daher wirkt sich die Verwendung der Select-Methode mit einem Selection-Objekt nur auf den Zustand des Objekts im Arbeitsspeicher aus. das Visio-Fenster ist nicht betroffen.

Die folgenden Konstanten, die in der Visio-Typbibliothek in VisSelectArgs deklariert sind, zeigen gültige Werte für Auswahltypen.

Konstante Wert Beschreibung
visDeselect 1 Hebt die Auswahl eines Shapes auf, aber die übrige Auswahl bleibt unverändert.
visSelect 2 Wählt ein Shape aus, aber die übrige Auswahl bleibt unverändert.
visSubSelect 3 Wählt ein Shape aus, dessen übergeordnetes Shape bereits ausgewählt ist.
visSelectAll 4 Wählt ein Shape und alle gleichrangigen Shapes aus.
visDeselectAll 256 Hebt die Auswahl eines Shapes und aller gleichrangigen Shapes auf.

Wenn SelectAction den Wert visSubSelect aufweist, muss das übergeordnete Shape von SheetObject bereits ausgewählt sein.

Sie können visDeselectAll mit visSelect und visSubSelect kombinieren, um die Auswahl für alle Shapes aufzuheben, bevor Sie andere Shapes auswählen.

Wenn es sich bei dem bearbeiteten Objekt um ein Selection-Objekt handelt und wenn mit der Select-Methode ein Shape-Objekt ausgewählt wird, dessen ContainingShape-Eigenschaft von der ContainingShape-Eigenschaft des Selection-Objekts abweicht, wird von der Select-Methode die Auswahl für alles aufgehoben, sogar wenn durch den Auswahltyp die Aufhebung der Auswahl nicht angegeben wurde.

Wenn es sich bei dem bearbeiteten Objekt um ein Window-Objekt handelt und wenn SelectAction nicht visSubSelect ist, muss es sich bei dem übergeordneten Shape von SheetObject um das Shape handeln, das von der ContainingShape-Eigenschaft des Window.Selection-Objekts zurückgegeben wurde.

Wenn Ihre Visual Studio-Projektmappe die Microsoft.Office.Interop.Visio-Referenz enthält, wird diese Methode den folgenden Typen zugeordnet:

  • Microsoft.Office.Interop.Visio.IVWindow.Select(Microsoft.Office.Interop.Visio.Shape, kurz)

Beispiel

Mit diesem VBA-Makro (Microsoft Visual Basic für Applikationen) wird gezeigt, wie Shapes ausgewählt werden, wie die Auswahl von Shape aufgehoben wird und wie Shapes untergeordnet ausgewählt werden.

 
Public Sub Select_Example()  
 
    Const MAX_SHAPES = 6  
    Dim vsoShapes(1 To MAX_SHAPES) As Visio.Shape  
    Dim intCounter As Integer  
 
    'Draw six rectangles.  
    For intCounter = 1 To MAX_SHAPES  
        Set vsoShapes(intCounter) = ActivePage.DrawRectangle(intCounter, intCounter + 1, intCounter + 1, intCounter)  
    Next intCounter  
 
    'Cancel the selection of all the shapes on the page.  
    ActiveWindow.DeselectAll  
 
     'Create a Selection object. 
    Dim vsoSelection As Visio.Selection  
    Set vsoSelection = ActiveWindow.Selection  
 
    'Select the first three shapes on the page. 
    For intCounter = 1 To 3  
        vsoSelection.Select vsoShapes(intCounter), visSelect  
    Next intCounter  
 
    'Group the selected shapes.  
    'Although the first three shapes are now grouped, the  
    'array vsoShapes() still contains them. 
    Dim vsoGroup As Visio.Shape  
    Set vsoGroup = vsoSelection.Group 
 
    'There are now four shapes on the page: a group that contains three  
    'subshapes, and three ungrouped shapes. Subselection is  
    'accomplished by selecting the parent shape first or one of the  
    'group's shapes already subselected.  
 
    'Select parent (group) shape. 
    ActiveWindow.Select vsoGroup, visDeselectAll + visSelect  
 
    'Subselect two of the shapes in the group. 
    ActiveWindow.Select vsoShapes(1), visSubSelect  
    ActiveWindow.Select vsoShapes(3), visSubSelect  
 
     'At this point two shapes are subselected, but we want to  
    'start a new selection that includes the last two shapes  
    'added to the page and the group. 
 
    'Note that the subselections that were made in the group  
    'are canceled by selecting another shape that is 
    'at the same level as the parent of the subselected shapes.  
 
    'Select just one shape. 
     ActiveWindow.Select vsoShapes(MAX_SHAPES), _  
        visDeselectAll + visSelect  
 
    'Select another shape. 
    ActiveWindow.Select vsoShapes(MAX_SHAPES - 1), visSelect  
 
    'Select the group.  
    ActiveWindow.Select vsoGroup, visSelect  
 
    'Select all but one shape on the page.  
    ActiveWindow.SelectAll  
    ActiveWindow.Select vsoShapes(MAX_SHAPES - 1), visDeselect  
 
End Sub

Support und Feedback

Haben Sie Fragen oder Feedback zu Office VBA oder zu dieser Dokumentation? Unter Office VBA-Support und Feedback finden Sie Hilfestellung zu den Möglichkeiten, wie Sie Support erhalten und Feedback abgeben können.