CanvasShapes.Range method (Word)
Returns a ShapeRange object.
Syntax
expression.Range (Index)
expression Required. A variable that represents a CanvasShapes object.
Parameters
Name | Required/Optional | Data type | Description |
---|---|---|---|
Index | Required | Variant | Specifies which shapes are to be included in the specified range. Can be an integer that specifies the index number of a shape within the Shapes collection, a string that specifies the name of a shape, or a array that contains integers or strings. |
Return value
ShapeRange
Remarks
Character position values begin with 0 (zero) at the beginning of the document. All characters are counted, including nonprinting characters. Hidden characters are counted even if they're not displayed.
ShapeRange objects don't include InlineShape objects. An InlineShape object is equivalent to a character and is positioned as a character within a range of text. Shape objects are anchored to a range of text (the selection, by default), but they can be positioned anywhere on the page. A Shape object will always appear on the same page as the range it is anchored to.
Most operations that you can do with a Shape object you can also do with a ShapeRange object that contains a single shape. Some operations, when performed on a ShapeRange object that contains multiple shapes, produce an error.
Example
This example selects and deletes the shapes in the first shape in the active document. This example assumes that the first shape is a canvas shape.
Sub CanvasShapeRange()
Dim rngCanvasShapes As Range
Set rngCanvasShapes = ActiveDocument.Shapes(1).CanvasItems.Range(1)
rngCanvasShapes.Select
rngCanvasShapes.Delete
End Sub
See also
Support and feedback
Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.