Share via


Bookmark.MoveStart(Object, Object) Method

Definition

Moves the start position of the Bookmark control.

public int MoveStart (ref object unit, ref object count);
abstract member MoveStart : obj * obj -> int
Public Function MoveStart (Optional ByRef unit As Object, Optional ByRef count As Object) As Integer

Parameters

unit
Object

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

count
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.

Returns

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.

Examples

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);
                
}
Private Sub BookmarkMoveStart()

    Me.Paragraphs(1).Range.InsertParagraphBefore()
    Me.Paragraphs(1).Range.Text = "This is sample text."
    Dim Bookmark1 As Microsoft.Office.Tools.Word.Bookmark = _
        Me.Controls.AddBookmark(Me.Paragraphs(1).Range.Words(3), _
        "Bookmark1")

    MessageBox.Show("First word of bookmark prior to calling MoveStart: " _
        & Bookmark1.Words.First.Text)

    Bookmark1.MoveStart(Word.WdUnits.wdCharacter, 4)
    
    MessageBox.Show("First word of bookmark prior to calling MoveStart: " _
        & Bookmark1.Words.First.Text)
End Sub

Remarks

Optional Parameters

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

Applies to