Share via


Bookmark.StartOf Method

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)

Syntax

'Declaration
Function StartOf ( _
    ByRef unit As Object, _
    ByRef extend As Object _
) As Integer
int StartOf(
    ref Object unit,
    ref Object extend
)

Parameters

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.

Remarks

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.

Optional Parameters

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

Examples

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 Sub BookmarkStartOf()

    Me.Paragraphs(1).Range.InsertParagraphBefore()
    Me.Paragraphs(1).Range.InsertParagraphBefore()
    Me.Paragraphs(1).Range.Text = "First paragraph of text." 
    Dim Bookmark1 As Microsoft.Office.Tools.Word.Bookmark = _
        Me.Controls.AddBookmark(Me.Paragraphs(1).Range, "Bookmark1")

    Bookmark1.Text = "This is sample bookmark text."
    Bookmark1.StartOf(Word.WdUnits.wdWord, _
        Word.WdMovementType.wdMove)

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

    bookmark1.StartOf(ref Unit, ref Extend);
}

.NET Framework Security

See Also

Reference

Bookmark Interface

Microsoft.Office.Tools.Word Namespace