Application.ObjectType 属性 (Visio)
返回对象的类型。 此为只读属性。
语法
表达式。ObjectType
expression:表示 Application 对象的变量。
返回值
整数
备注
代表对象类型的常量以 visObjType 作为前缀,并由 Visio 类型库在 VisObjectTypes 中声明。
示例
以下示例说明如何使用页面的 ObjectType 属性以递归方式遍历组以及标识顶层形状。
Public Sub ObjectType_Example()
Dim vsoShape As Visio.Shape
Dim vsoShapes As Visio.Shapes
Dim vsoPage As Visio.Page
Application.ActiveWindow.Page.Drop Application.Documents.Item("BASIC_U.VSS").Masters.ItemU("Pentagon"), 3#, 8.5
Application.ActiveWindow.Page.Drop Application.Documents.Item("BASIC_U.VSS").Masters.ItemU("Ellipse"), 3#, 7.625
Application.ActiveWindow.Page.Drop Application.Documents.Item("BASIC_U.VSS").Masters.ItemU("Rounded rectangle"), 3#, 7#
Application.ActiveWindow.Page.Drop Application.Documents.Item("BASIC_U.VSS").Masters.ItemU("Circle"), 3#, 6.25
Application.ActiveWindow.SelectAll
ActiveWindow.DeselectAll
ActiveWindow.Select Application.ActiveWindow.Page.Shapes.ItemU("Circle"), visSelect
ActiveWindow.Select Application.ActiveWindow.Page.Shapes.ItemU("Rounded rectangle"), visSelect
ActiveWindow.Select Application.ActiveWindow.Page.Shapes.ItemU("Ellipse"), visSelect
ActiveWindow.Select Application.ActiveWindow.Page.Shapes.ItemU("Pentagon"), visSelect
ActiveWindow.Selection.Group
Set vsoPage = ActivePage
Set vsoShapes = vsoPage.Shapes
Set vsoShape = vsoShapes.Item(2)
Call GetTopShape(vsoShape)
End Sub
Function GetTopShape(vsoShape As Visio.Shape) As String
Dim vsoShapeParent As Object
Dim vsoShapeParentParent As Object
Set vsoShapeParent = vsoShape.Parent
If vsoShapeParent.ObjectType = visObjTypeShape Then
Set vsoShapeParentParent = vsoShapeParent.Parent
'If vsoShapeParent's parent isn't a page, keep going up.
If vsoShapeParentParent.ObjectType = visObjTypePage Then
GetTopShape = vsoShapeParent.Name
Else
GetTopShape = GetTopShape(vsoShapeParent)
End If
End If
Debug.Print vsoShapeParent.Name
End Function
支持和反馈
有关于 Office VBA 或本文档的疑问或反馈? 请参阅 Office VBA 支持和反馈,获取有关如何接收支持和提供反馈的指南。