Bookmark.Next Method (Object, Object)

 

Gets a Range object that represents the specified unit relative to the Bookmark control.

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

Range Next(
	ref object Unit,
	ref object Count
)

Parameters

Unit
Type: System.Object

The type of units by which to count. Can be any T:Microsoft.Office.Interop.Word.WdUnits constant.

Count
Type: System.Object

The number of units by which you want to move ahead. The default value is one.

Return Value

Type: Microsoft.Office.Interop.Word.Range

A Range object that represents the specified unit relative to the Bookmark control.

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, inserts additional text after the bookmark, and then displays the next word after the bookmark in a message box.

This example is for a document-level customization.

private void BookmarkNext()
{
    this.Paragraphs[1].Range.InsertParagraphBefore();
    Microsoft.Office.Tools.Word.Bookmark bookmark1 =
        this.Controls.AddBookmark(this.Paragraphs[1].Range,
        "bookmark1");
    bookmark1.Text = "This is sample bookmark text.";
    bookmark1.InsertAfter (" This text is inserted after the bookmark.");

    object Unit = Word.WdUnits.wdWord;
    object Count = 1;

    Word.Range range1 = bookmark1.Next(ref Unit, ref Count);

    MessageBox.Show("The next word after Bookmark1 is at " +	
        "position " + range1.Start + " through " + range1.End);
}
Return to top
Show: