Compartilhar via


Método Selection.Select (Visio)

Marca ou desmarca a seleção de um objeto.

Sintaxe

expressão. Selecione (SheetObject, SelectAction)

Expressão Uma variável que representa um objeto Selection .

Parâmetros

Nome Obrigatório/Opcional Tipo de dados Descrição
SheetObject Obrigatório [IVSHAPE] Uma expressão que retorna um objeto Shape a ser selecionado ou desmarcado.
Selectaction Obrigatório Integer O tipo de ação de seleção a tomar.

Valor de retorno

Nada

Comentários

Quando usado com o objeto Window, o método Select afetará a seleção na janela do Microsoft Visio. Contudo, o objeto Selection é independente da seleção na janela. Portanto, usar o método Select com um objeto Selection afeta apenas o estado do objeto na memória; a janela do Visio não é afetada.

As constantes a seguir declaradas pela biblioteca de tipos do Visio em VisSelectArgs mostram valores válidos para tipos de seleção.

Constant Valor Descrição
visDeselect 1 Cancela a seleção de uma forma, mas deixa o restante da seleção inalterada.
visSelect 2 Seleciona uma forma mas deixa o resto da seleção inalterada.
visSubSelect 3 Seleciona uma forma cujo pai já está selecionado.
visSelectAll 4 Seleciona uma forma e todos os seus pares.
visDeselectAll 256 Cancela a seleção de uma forma e todos os seus pares.

Se SelectAction for visSubSelect, a forma pai de SheetObject já deverá estar selecionada.

Você pode combinar visDeselectAll com visSelect e visSubSelect para cancelar a seleção de todas as formas antes de selecionar ou subselecionar outras formas.

Se o objeto em operação for um objeto Selection e se o método Select selecionar um objeto Shape cuja propriedade ContainingShape é diferente da propriedade ContainingShape do objeto Selection, o método Select desmarcará tudo, mesmo que o valor do tipo de seleção não especifique o cancelamento da seleção.

Se o objeto em operação for um objeto Window e se SelectAction não for visSubSelect, a forma pai de SheetObject deverá ser a mesma forma que a retornada pela propriedade ContainingShape do objeto Window.Selection.

Exemplo

Esta macro do Microsoft VBA (Visual Basic for Applications) mostra como selecionar, desmarcar e subselecionar formas.

 
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

Suporte e comentários

Tem dúvidas ou quer enviar comentários sobre o VBA para Office ou sobre esta documentação? Confira Suporte e comentários sobre o VBA para Office a fim de obter orientação sobre as maneiras pelas quais você pode receber suporte e fornecer comentários.