Nota:
El acceso a esta página requiere autorización. Puede intentar iniciar sesión o cambiar directorios.
El acceso a esta página requiere autorización. Puede intentar cambiar los directorios.
Devuelve la capa a la que está asignada una forma. Solo lectura.
Sintaxis
expresión.
Layer (Índice)
expresión Variable que representa un objeto Shape.
Parameters
| Nombre | Obligatorio/opcional | Tipo de datos | Descripción |
|---|---|---|---|
| Index | Obligatorio | Integer | Ordinal de la capa que se desea obtener. |
Valor devuelto
Layer
Observaciones
Si se asigna una forma a tres capas, los índices válidos que se pueden pasar a su propiedad Layer son de 1 a 3.
Para obtener el número de capas a las que está asignada una forma, utilice la propiedad LayerCount.
Ejemplo
Esta macro de Microsoft Visual Basic para Aplicaciones (VBA) muestra cómo utilizar la propiedad Layer para obtener una referencia a una capa determinada. También utiliza la propiedad LayerCount para determinar el número de capas a las que está asignada una forma y la propiedad Name para obtener el nombre de la capa actual.
Public Sub Layer_Example()
Dim vsoPage As Visio.Page
Dim vsoShape As Visio.Shape
Dim vsoLayers As Visio.Layers
Dim vsoLayer As Visio.Layer
If ActiveDocument Is Nothing Then
Documents.Add ("")
End If
Set vsoPage = ActivePage
If vsoPage Is Nothing Then
Set vsoPage = ActiveDocument.Pages(1)
End If
'Draw a rectangle.
Set vsoShape = vsoPage.DrawRectangle(1, 5, 5, 1)
'Get the Layers collection.
Set vsoLayers = vsoPage.Layers
'Create a layer named ExampleLayer1 and add the shape to it.
Set vsoLayer = vsoLayers.Add("ExampleLayer1")
vsoLayer.Add vsoShape, 1
'Create a layer named ExampleLayer2 and add the shape to it.
Set vsoLayer = vsoLayers.Add("ExampleLayer2")
vsoLayer.Add vsoShape, 1
'Verify that the shape has been assigned to 2 layers.
Debug.Print "The rectangle is assigned to " & vsoShape.LayerCount & " layers."
'Get a reference to the first layer.
Set vsoLayer = vsoShape.Layer(1)
'Verify by using the Name property.
Debug.Print "Current vsoLayer name is """ & vsoLayer.Name & "."""
End Sub
Soporte técnico y comentarios
¿Tiene preguntas o comentarios sobre VBA para Office o esta documentación? Vea Soporte técnico y comentarios sobre VBA para Office para obtener ayuda sobre las formas en las que puede recibir soporte técnico y enviar comentarios.