Expand Minimize

Bookmark.EndOf Method

Moves or extends the ending character position of a Bookmark control to the end of the nearest text unit.

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

int EndOf(
	ref Object unit,
	ref Object extend
)

Parameters

unit
Type: System.Object

The unit by which to move the ending character position. WdUnits.

extend
Type: System.Object

WdMovementType.

Return Value

Type: System.Int32
The number of character positions the Bookmark was extended.

If both the starting and ending positions for the Bookmark control are already at the end of the unit, this method does not move or extend the Bookmark control.

Optional Parameters

For information on optional parameters, see Optional Parameters in Office Solutions.

The following code example adds a Bookmark control with text to the document and then adds additional text after the bookmark. It then extends the bookmark by one word.

This example is for a document-level customization.

private void BookmarkEndOf()
{
    object Unit = Word.WdUnits.wdWord;
    object Extend = Word.WdMovementType.wdMove;
    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. ";
    bookmark1.InsertAfter("This text is inserted after the bookmark.");
    bookmark1.EndOf(ref Unit, ref Extend);
}

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2015 Microsoft