Bookmark.MoveEnd Method (Object, Object)


Moves the ending character position of a Bookmark control.

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

int MoveEnd(
	ref object unit,
	ref object count


Type: System.Object

The unit by which to move the ending character position.

Type: System.Object

The number of units to move. If this number is positive, the ending character position is moved forward in the document. If this number is negative, the end is moved backward. If the ending position overtakes the starting position, the range collapses and both character positions move together. The default value is 1.

Return Value

Type: System.Int32

The number of units the Bookmark control actually moved, or it returns 0 (zero) if the move was unsuccessful.

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

The following code example adds a Bookmark control with text to the first paragraph and displays the last word of the bookmark in a message box. The code then calls the MoveEnd method and displays the last word of the bookmark in a new message box.

This example is for a document-level customization.

private void BookmarkMoveEnd()
    this.Paragraphs[1].Range.Text = "This is sample text.";
    Microsoft.Office.Tools.Word.Bookmark bookmark1 =

    object Unit = Word.WdUnits.wdWord;
    object Count = 1;

    MessageBox.Show("Last word of bookmark prior to calling MoveEnd: "
        + bookmark1.Words.Last.Text);

    bookmark1.MoveEnd(ref Unit, ref Count);

    MessageBox.Show("Last word of bookmark after calling MoveEnd: "
        + bookmark1.Words.Last.Text);

Return to top