Share via


Bookmark.SetRange(Int32, Int32) Method

Definition

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

public:
 void SetRange(int start, int end);
public void SetRange (int start, int end);
abstract member SetRange : int * int -> unit
Public Sub SetRange (start As Integer, end As Integer)

Parameters

start
Int32

The starting character position of the Bookmark control.

end
Int32

The ending character position of the 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 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);
}
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

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.

Applies to