Bookmark.Previous Method (Object, Object)

 

Gets a Range object relative to the Bookmark control.

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

Range Previous(
	ref object Unit,
	ref object Count
)

Parameters

Unit
Type: System.Object

T:Microsoft.Office.Interop.Word.WdUnits.

Count
Type: System.Object

The number of units by which you want to move back. The default value is 1.

Return Value

Type: Microsoft.Office.Interop.Word.Range

A Range object relative to the Bookmark control.

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

The following code example adds text to the first paragraph and then adds a Bookmark control to the second word. The code then selects the word previous to the bookmark.

This example is for a document-level customization.

private void BookmarkPrevious()
{
    this.Paragraphs[1].Range.InsertParagraphBefore();
    this.Paragraphs[1].Range.Text = "Text before the bookmark.";
    Microsoft.Office.Tools.Word.Bookmark bookmark1 =
        this.Controls.AddBookmark(this.Paragraphs[1].Range.Words[2],
        "bookmark1");

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

    bookmark1.Previous(ref Unit, ref Count).Select();
}
Return to top
Show: