Bookmark.Previous Method

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)

Syntax

'Declaration
Function Previous ( _
    ByRef Unit As Object, _
    ByRef Count As Object _
) As Range
Range Previous(
    ref Object Unit,
    ref Object Count
)

Parameters

  • 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.

Remarks

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 to the second word. The code then selects the word previous to the bookmark.

This example is for a document-level customization.

Private Sub BookmarkPrevious()

    Me.Paragraphs(1).Range.InsertParagraphBefore()
    Me.Paragraphs(1).Range.Text = "Text before the bookmark." 

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

    Bookmark1.Previous(Word.WdUnits.wdWord, 1).Select()

End Sub
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();
}

.NET Framework Security

See Also

Reference

Bookmark Interface

Microsoft.Office.Tools.Word Namespace