Share via


Bookmark.SetRange Method

Sets the starting and ending character positions for the Bookmark control.

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

Syntax

'Declaration
Sub SetRange ( _
    start As Integer, _
    end As Integer _
)
void SetRange(
    int start,
    int end
)

Parameters

Remarks

Character position values start at the beginning of the story, with the first value being 0 (zero). All characters are counted, including nonprinting characters. Hidden characters are counted even if they are not displayed.

The SetRange method redefines the starting and ending positions of an existing Bookmark control.

Examples

The following code example adds a Bookmark control with text to the document and then sets the range of the bookmark to the first character in the document.

Private Sub BookmarkSetRange()

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

    Bookmark1.Text = "First Bookmark"
    Bookmark1.SetRange(1, 1)

End Sub
private void BookmarkSetRange()
{
    this.Paragraphs[1].Range.InsertParagraphBefore();
    Microsoft.Office.Tools.Word.Bookmark bookmark1 =
        this.Controls.AddBookmark(this.Paragraphs[1].Range,
        "bookmark1");
    bookmark1.Text = "First Bookmark";

    int Start = 1;
    int End = 1;

    bookmark1.SetRange(Start, End);
}

.NET Framework Security

See Also

Reference

Bookmark Interface

Microsoft.Office.Tools.Word Namespace