ShapeRange Property
TOC
Collapse the table of content
Expand the table of content

Bookmark.ShapeRange Property

 

Gets a ShapeRange collection that represents all the Shape objects in the Bookmark control.

Namespace:   Microsoft.Office.Tools.Word
Assembly:  Microsoft.Office.Tools.Word (in Microsoft.Office.Tools.Word.dll)

ShapeRange ShapeRange { get; }

Property Value

Type: Microsoft.Office.Interop.Word.ShapeRange

A ShapeRange collection that represents all the Shape objects in the Bookmark control.

The shape range can contain drawings, shapes, pictures, OLE objects, ActiveX controls, text objects, and callouts.

The following code example adds a Bookmark control with text to the document and then uses the vertical and horizontal positions of the bookmark when creating a text box. It then displays the name of the ShapeRange within the bookmark in a message box.

This example is for a document-level customization.

private void BookmarkShapeRange()
{
    this.Paragraphs[1].Range.InsertParagraphBefore();
    Microsoft.Office.Tools.Word.Bookmark bookmark1 =
        this.Controls.AddBookmark(this.Paragraphs[1].Range,
        "bookmark1");
    bookmark1.Text = "This is sample bookmark text.";

    object myRange = bookmark1.Range;
    object vertical = bookmark1.Information[Microsoft.Office
        .Interop.Word.WdInformation.wdVerticalPositionRelativeToPage];
    object horizontal = bookmark1.Information[Microsoft.Office
        .Interop.Word.WdInformation.wdHorizontalPositionRelativeToPage];

    Word.Shape shape = this.Shapes.AddTextbox(Microsoft.Office.Core
        .MsoTextOrientation.msoTextOrientationHorizontal, (float)vertical, 
        (float)horizontal, 50, 50, ref missing);

    MessageBox.Show(bookmark1.ShapeRange.Name.ToString());
}
Return to top
Show:
© 2016 Microsoft