Visio VBA函数,查看是否存在';在形状的前面/后面有一个形状

Visio VBA函数,查看是否存在';在形状的前面/后面有一个形状,vba,visio,shapes,Vba,Visio,Shapes,在Visio VBA中是否有方法查看Visio中某个形状的前面或后面是否有某个形状 我想我可以写一些东西来检查页面中每个形状的边界框,看看它是否与我的形状占用相同的空间。 我更喜欢使用内置的东西,因为检查每个形状可能需要很长时间,因为图形中的形状越来越多。shape.SpatialRelation属性将告诉您两个形状是否接触。Index属性将告诉您在z顺序中哪个在前面或后面 下面是一个简单的例子: Public Sub DoShapesIntersect(ByRef shape1 As Visi

在Visio VBA中是否有方法查看Visio中某个形状的前面或后面是否有某个形状

我想我可以写一些东西来检查页面中每个形状的边界框,看看它是否与我的形状占用相同的空间。
我更喜欢使用内置的东西,因为检查每个形状可能需要很长时间,因为图形中的形状越来越多。

shape.SpatialRelation属性将告诉您两个形状是否接触。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
Public Sub-doshapeintersect(ByRef shape1作为Visio.Shape,ByRef shape2作为Visio.Shape)
//他们会碰吗?
如果(shape1.空间关系(shape2,0,0)0),那么
//他们碰了一下,哪一个在前面?
如果(shape1.Index>shape2.Index),则
Debug.Print shape1.Name+位于“+shape2.Name”前面
其他的
Debug.Print shape1.Name+“在“+shape2.Name”后面
如果结束
其他的
调试。打印“shape1和shape2不接触”
如果结束
端接头
请在此处阅读更多信息: