Export (0) Print
Expand All
Expand Minimize

Bookmark.MoveStart Method

Moves the start position of the Bookmark control.

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

int MoveStart(
	ref Object unit,
	ref Object count
)

Parameters

unit
Type: System.Object

WdUnits. The unit by which start position of the specified range or selection is to be moved.

count
Type: System.Object

The maximum number of units by which the Bookmark control is to be moved. If Count is a positive number, the start position of the Bookmark control is moved forward in the document. If it is a negative number, the start position is moved backward. If the start position is moved forward to a position beyond the end position, the Bookmark control is collapsed and both the start and end positions are moved together. The default value is 1.

Return Value

Type: System.Int32
The number of units by which the start position of the Bookmark control actually moved, or it returns 0 (zero) if the move was unsuccessful.

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 first paragraph and then moves the start position of the bookmark.

This example is for a document-level customization.

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

    object Unit = Word.WdUnits.wdCharacter;
    object Count = 3;

    bookmark1.MoveStart(ref Unit, ref Count);

}

Show:
© 2015 Microsoft