Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All
Expand Minimize

SpatialNeighbors property

SpatialNeighbors property

This content is no longer actively maintained. It is provided as is, for anyone who may still be using these technologies, with no warranties or claims of accuracy with regard to the most recent product version or service release.

https://msdn.microsoft.com/en-us/library/aa191379(v=office.10) See also         https://msdn.microsoft.com/en-us/library/aa155679(v=office.10) Example         https://msdn.microsoft.com/en-us/library/aa164278(v=office.10) Applies to

Returns a Selection object that represents the shapes that meet certain criteria in relation to a specified shape.

Version added



objRet = object.SpatialNeighbors(relation, tolerance, flags[,resultRoot])


A Selection object.


Required. An expression that returns a Shape object.


Required Integer. An integer describing the type of relationship to be used.


Required Double. A distance in internal drawing units with respect to the coordinate space defined by the parent shape.


Required Integer. Flags that influence the type of entries returned in results.


Optional Variant. A Shape object that represents a page or group.


For values of the relation argument, see the https://msdn.microsoft.com/en-us/library/aa191376(v=office.10) SpatialRelation property.

The flags argument can be any combination of the values of the constants defined in the following table. These constants are also defined in VisSpatialRelationFlags in the Visio type library.






Consider a guide's https://msdn.microsoft.com/en-us/library/aa200706(v=office.10) Geometry section. By default, guides do not influence the result.



Order items front to back.



Order items back to front.



Consider hidden Geometry sections. By default, hidden Geometry sections do not influence the result.



Do not consider visible Geometry sections. By default, visible Geometry sections influence the result.

Use the https://msdn.microsoft.com/en-us/library/aa157269(v=office.10) NoShow cell to determine whether a Geometry section is hidden or visible. Hidden Geometry sections have a value of TRUE and visible Geometry sections have a value of FALSE in the NoShow cell.

Beginning with Visio 2002, if flags contains VisSpatialFrontToBack, items in the Selection object returned by the SpatialNeighbors property are ordered front to back. If visSpatialBackToFront is set, the items returned are ordered back to front. If this flag is not set, or if you are running an earlier version of Visio, the order is unpredictable. You can determine the order using the Index property of the shapes identified in the Selection object.

If you don't specify resultRoot, this property returns a Selection object that represents the shapes that meet certain criteria in relation to the specified shape. If you specify resultRoot, this property returns a Selection object that represents all the shapes in the Shape object specified by resultRoot that meet certain criteria in relation to the specified shape. For example, specify resultRoot to find all shapes within a group that are near a specified shape.

If resultRoot is specified but isn't on the same page or in the same master as the Shape object to which you are comparing it, the SpatialNeighbors property raises an exception and returns Nothing.

If relation is not specified, the SpatialNeighbors property uses all the possible relationships as criteria.

The SpatialNeighbors property does not consider the width of a shape's line, shadows, line ends, control points, or connection points when comparing two shapes.

© 2015 Microsoft