Shape.Layer 属性 (Visio)
返回为其分配形状的图层。 此为只读属性。
语法
expression。 Layer
(索引)
表达 一个代表 Shape 对象的变量。
参数
名称 | 必需/可选 | 数据类型 | 说明 |
---|---|---|---|
Index | 必需 | Integer | 要获取的图层的序号。 |
返回值
层
备注
如果一个形状被分配到三个图层,则可以传递给其 Layer 属性的有效索引为 1 到 3。
要获取为其分配形状的图层的数目,请使用 LayerCount 属性。
示例
以下 Microsoft Visual Basic for Applications (VBA) 宏显示如何使用 Layer 属性获取对特定图层的引用。 该宏还使用 LayerCount 属性确定为其分配形状的图层的数目,使用 Name 属性获取当前图层的名称。
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
支持和反馈
有关于 Office VBA 或本文档的疑问或反馈? 请参阅 Office VBA 支持和反馈,获取有关如何接收支持和提供反馈的指南。
反馈
https://aka.ms/ContentUserFeedback。
即将发布:在整个 2024 年,我们将逐步淘汰作为内容反馈机制的“GitHub 问题”,并将其取代为新的反馈系统。 有关详细信息,请参阅:提交和查看相关反馈