Code:
Public Sub Document_ShapeAdded(ByVal vsoShapeAdded As IVShape)
Dim vsoShapeOnPage As Visio.Shape
Dim vsoDocument As Visio.Document
Dim vsoPage As Visio.Page
Dim vsoReturnedSelection As Visio.Selection
Dim intSpatialRelation As VisSpatialRelationCodes
intSpatialRelation = visSpatialOverlap + visSpatialContainedIn
Set vsoReturnedSelection = vsoShapeAdded.SpatialNeighbors(intSpatialRelation, 0, 0)
'Evaluate the results.
If vsoReturnedSelection.Count = 0 Then
'Aucune forme satisfait aux critères établis par les arguments de la méthode.
strSpatialRelation = vsoShapeAdded.Name & " is not contained."
Else
'Build the positive result string.
For Each vsoShapeOnPage In vsoReturnedSelection
If vsoShapeOnPage.Name Like "Function*" And vsoShapeAdded.Name Like "port*" Then
strSpatialRelation = strSpatialRelation & vsoShapeAdded.Name & " is contained by " & vsoShapeOnPage.Name & Chr$(10)
'---> Il faut coller les Shape avec la methode GlueTo
' expression.GlueTo (CellObject)
' expression Variable qui représente un objet Cell
End If
Next
End If
'Display the results on the shape added.
vsoShapeAdded.Text = strSpatialRelation
End Sub
I need your brains to solve a small problem that I have encountered just recently.
Indeed, My program is using the SpatialNeighbors property to find out if one shape is contained in another. if I have a Shape which is contained in an another Shape so I have to stick my shapes with the GlueTo method. But I have trouble using this method.
I'm using for the moment only 2-D shapes..
Thank you for your help