Application.ObjectType property (Visio)
Returns an object's type. Read-only.
Syntax
expression.ObjectType
expression A variable that represents an Application object.
Return value
Integer
Remarks
Constants representing object types are prefixed with visObjType and are declared by the Visio type library in VisObjectTypes.
Example
This example shows how to use the ObjectType property of a page to iterate recursively through a group and identify the top shape.
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
Support and feedback
Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.
피드백
https://aka.ms/ContentUserFeedback
출시 예정: 2024년 내내 콘텐츠에 대한 피드백 메커니즘으로 GitHub 문제를 단계적으로 폐지하고 이를 새로운 피드백 시스템으로 바꿀 예정입니다. 자세한 내용은 다음을 참조하세요.다음에 대한 사용자 의견 제출 및 보기