Bookmark.Previous Method (2007 System)

Gets a Range object relative to the Bookmark control.

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

Syntax

'Declaration
Public Function Previous ( _
    ByRef Unit As Object, _
    ByRef Count As Object _
) As Range
'Usage
Dim instance As Bookmark 
Dim Unit As Object 
Dim Count As Object 
Dim returnValue As Range 

returnValue = instance.Previous(Unit, _
    Count)
public Range Previous(
    ref Object Unit,
    ref Object Count
)
public:
Range^ Previous(
    Object^% Unit, 
    Object^% Count
)
public function Previous(
    Unit : Object, 
    Count : Object
) : Range

Parameters

  • Count
    Type: System.Object%

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

Return Value

Type: Range
A Range object relative to the Bookmark control.

Remarks

Optional Parameters

For information on optional parameters, see The Variable missing and 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 Class

Bookmark Members

Microsoft.Office.Tools.Word Namespace