문제

Visio VBA에는 Visio의 모양이 있는지 또는 뒤에 모양이 있는지 확인하는 방법이 있습니까?

나는 페이지에서 각 모양의 경계 상자를 확인하여 내 모양과 같은 공간을 차지하는지 확인하는 것을 쓸 수 있다고 생각합니다. 도면이 점점 더 많은 모양을 얻을 때 각 모양을 확인하는 데 오랜 시간이 걸릴 수 있기 때문에 내장을 사용하고 싶습니다.

도움이 되었습니까?

해결책

shape.patial relation 속성은 두 개의 모양이 터치하는지 알려줍니다. shape.index 속성은 z- 주문의 앞쪽 또는 뒤에 있는지 알려줍니다.

간단한 예는 다음과 같습니다.

Public Sub DoShapesIntersect(ByRef shape1 As Visio.Shape, ByRef shape2 As Visio.Shape)

    '// do they touch?
    If (shape1.SpatialRelation(shape2, 0, 0) <> 0) Then

        '// they touch, which one is in front?
        If (shape1.Index > shape2.Index) Then
            Debug.Print shape1.Name + " is in front of " + shape2.Name
        Else
            Debug.Print shape1.Name + " is behind " + shape2.Name
        End If
    Else
        Debug.Print "shape1 and shape2 do not touch"
    End If

End Sub

자세히보기 :

MSDN의 Shape.spatial Relation 속성

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top