Bookmark.EndOf Method (Object, Object)


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


Type: System.Object

The unit by which to move the ending character position. T:Microsoft.Office.Interop.Word.WdUnits.

Type: System.Object


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.

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;
    Microsoft.Office.Tools.Word.Bookmark bookmark1 =
    bookmark1.Text = "This is sample bookmark text. ";
    bookmark1.InsertAfter("This text is inserted after the bookmark.");
    bookmark1.EndOf(ref Unit, ref Extend);
Return to top