指定物件的名稱。 唯讀。
語法
運算式。名稱
運算式 代表 圖層 物件的變數。
傳回值
字串
註解
注意事項
從 Microsoft Visio 2000 開始,您可以使用本機和通用名稱來參照 Visio 圖形、母片、文件、頁面、列、附加元件、儲存格、超連結、樣式、字型、主片快速鍵、UI 物件和圖層。 例如,當使用者命名圖形時,使用者是在指定本機名稱。 從 Microsoft Office Visio 2003 開始,ShapeSheet 試算表僅顯示儲存格公式和值中的通用名稱。 (在舊版中,通用名稱在使用者介面中是看不見的。)
身為開發人員,如果您不希望每次將方案本土化時就要變更名稱,可以在程式中使用通用名稱。 使用 Name 屬性取得或設定 Hyperlink、Layer、Master、MasterShortcut、Page、Shape、Style 或 Row 物件的本機名稱。 使用 NameU 屬性取得或設定其通用名稱。
範例
下列 Microsoft Visual Basic for Applications (VBA) 巨集會示範如何使用 Name 屬性來顯示圖層名稱。 此巨集還會使用 Layer 屬性取得特定圖層的參考,並使用 LayerCount 屬性決定已有指派圖形的圖層數目。
Public Sub Name_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 page has " & 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 支援與意見反應。