Visio VBA で、Visio の図形の前または後ろに図形があるかどうかを確認する方法はありますか?
ページ内の各図形の境界ボックスをチェックして、それが自分の図形と同じスペースを占めているかどうかを確認するものを作成できると思います。図面の形状がどんどん増えるにつれて、各形状をチェックするのに時間がかかる可能性があるため、組み込みのものを使用したいと思います。
Shape.SpatialRelation プロパティは、2 つの図形が接触しているかどうかを示します。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
ここでもっと読む: