Freigeben über


Bookmark.Previous(Object, Object) Method

Definition

Gets a Range object relative to the Bookmark control.

public Microsoft.Office.Interop.Word.Range Previous (ref object Unit, ref object Count);
abstract member Previous : obj * obj -> Microsoft.Office.Interop.Word.Range
Public Function Previous (Optional ByRef Unit As Object, Optional ByRef Count As Object) As Range

Parameters

Count
Object

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

Returns

A Range object relative to the Bookmark control.

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

Remarks

Optional Parameters

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

Applies to