共用方式為


Bookmark.Next 方法

取得 Range 物件,表示與 Bookmark 控制項相關的指定單元。

命名空間:  Microsoft.Office.Tools.Word
組件:  Microsoft.Office.Tools.Word (在 Microsoft.Office.Tools.Word.dll 中)

語法

'宣告
Function Next ( _
    ByRef Unit As Object, _
    ByRef Count As Object _
) As Range
Range Next(
    ref Object Unit,
    ref Object Count
)

參數

  • Count
    型別:System.Object%
    您想要往前移動的單元數目。預設值為 1。

傳回值

型別:Microsoft.Office.Interop.Word.Range
Range 物件,表示與 Bookmark 控制項相關的指定單元。

備註

選擇性參數

如需選擇性參數的詳細資訊,請參閱Office 方案中的選擇性參數

範例

下列程式碼範例將有文字的 Bookmark 控制項加入至第一個段落,並在書籤後插入其他的文字,然後在訊息方塊中顯示書籤後的下一個字。

這是示範文件層級自訂的範例。

Private Sub BookmarkNext()

    Me.Paragraphs(1).Range.InsertParagraphBefore()
    Dim Bookmark1 As Microsoft.Office.Tools.Word.Bookmark = _
        Me.Controls.AddBookmark(Me.Paragraphs(1).Range, "Bookmark1")
    Bookmark1.Text = "This is sample bookmark text."
    Bookmark1.InsertAfter(" This text is inserted after " & _
        "the bookmark.")

    Dim Range1 As Word.Range = Bookmark1.Next( _
        Word.WdUnits.wdWord, 1)

    MessageBox.Show("The next word after Bookmark1 is at " & _
        "position " & Range1.Start.ToString & " through " & _
        Range1.End.ToString)

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

.NET Framework 安全性

請參閱

參考

Bookmark 介面

Microsoft.Office.Tools.Word 命名空間