Bookmark.StartOf Method (Object, Object)


Moves or extends the start position of the Bookmark control to the beginning of the nearest specified text unit.

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

int StartOf(
	ref object unit,
	ref object extend


Type: System.Object

T:Microsoft.Office.Interop.Word.WdUnits. The unit by which the start position of the Bookmark control is to be moved.

Type: System.Object


Return Value

Type: System.Int32

The number of characters by which the Bookmark control was moved or extended. The method returns a negative number if the movement is backward through the document.

If the beginning of the Bookmark control is already at the beginning of the specified 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 text to the first paragraph and then adds a Bookmark control with text to the second paragraph. The code then moves the start of the bookmark over one word.

This example is for a document-level customization.

private void BookmarkStartOf()
    object Unit = Word.WdUnits.wdWord;
    object Extend = Word.WdMovementType.wdExtend;
    this.Paragraphs[1].Range.Text = "First paragraph of text.";
    this.Paragraphs[2].Range.Text = "Second paragraph of text.";
    Microsoft.Office.Tools.Word.Bookmark bookmark1 =

    bookmark1.StartOf(ref Unit, ref Extend);
Return to top