共用方式為


Bookmark.SelectionChange 事件

會在 Bookmark 控制項內的選取範圍變更時發生。

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

語法

'宣告
Event SelectionChange As SelectionEventHandler
event SelectionEventHandler SelectionChange

備註

當選取範圍變更為 Bookmark 控制項,或此控制項內的選取範圍有所變更時,便會引發這個事件。

範例

下列程式碼範例將有文字的 Bookmark 控制項加入至文件的第一個段落,然後建立 SelectionChange 事件處理常式。當游標移入書籤內時,便會顯示訊息方塊。

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

WithEvents Bookmark5 As Microsoft.Office.Tools.Word.Bookmark

Private Sub BookmarkSelectionChange()
    Me.Paragraphs(1).Range.InsertParagraphBefore()
    Bookmark5 = Me.Controls.AddBookmark(Me.Paragraphs(1).Range, _
        "Bookmark5")
    Bookmark5.Text = "This is a sample bookmark."
End Sub

Private Sub Bookmark5_SelectionChange(ByVal sender As Object, _
    ByVal e As Microsoft.Office.Tools.Word.SelectionEventArgs) _
    Handles Bookmark5.SelectionChange
    MessageBox.Show("The selection has changed within Bookmark1.")
End Sub
Microsoft.Office.Tools.Word.Bookmark bookmark5;

private void BookmarkSelectionChange()
{
    this.Paragraphs[1].Range.InsertParagraphBefore();
    bookmark5 = this.Controls.AddBookmark(this.Paragraphs[1]
        .Range, "bookmark5");
    bookmark5.Text = "This is a sample bookmark.";
    bookmark5.SelectionChange += new Microsoft.Office.Tools.Word.SelectionEventHandler(bookmark5_SelectionChange);
}

void bookmark5_SelectionChange(object sender, Microsoft.Office.Tools.Word.SelectionEventArgs e)
{
    MessageBox.Show("The selection has changed within bookmark1.");
}

.NET Framework 安全性

請參閱

參考

Bookmark 介面

Microsoft.Office.Tools.Word 命名空間