Función Visio VBA para ver si hay una forma delante / detrás de una forma
Pregunta
¿Hay alguna manera en Visio VBA para ver si hay una figura delante o detrás de una figura en Visio?
Me imagino que podría escribir algo que marque el cuadro delimitador de cada forma en una página para ver si ocupa el mismo espacio que mi forma. Prefiero usar algo incorporado, ya que la verificación de cada forma puede llevar mucho tiempo, ya que un dibujo obtiene más y más formas.
Solución
La propiedad Shape.SpatialRelation te dirá si se tocan dos formas. La propiedad Shape.Index le dirá cuál está delante o detrás en el orden z.
Aquí hay un ejemplo simple:
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
Lea más aquí:
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow