Document.SelectionChange 事件
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
在文档窗口中的选定内容发生更改时发生。
event Microsoft.Office.Tools.Word.SelectionEventHandler SelectionChange;
事件类型
示例
下面的代码示例显示一条消息,指示每当你更改文档中的选定内容时,所选内容已更改。 此示例适用于应用程序级外接程序。
private void DocumentSelectionChange()
{
Document vstoDoc = Globals.Factory.GetVstoObject(this.Application.ActiveDocument);
vstoDoc.SelectionChange += new Microsoft.Office.Tools.Word.SelectionEventHandler(ThisDocument_SelectionChange);
}
void ThisDocument_SelectionChange(object sender, Microsoft.Office.Tools.Word.SelectionEventArgs e)
{
System.Windows.Forms.MessageBox.Show("The selection in the document has changed.");
}
Private Sub DocumentSelectionChange()
Dim vstoDoc As Document = Globals.Factory.GetVstoObject(Me.Application.ActiveDocument)
AddHandler vstoDoc.SelectionChange, AddressOf ThisDocument_SelectionChange
End Sub
Private Sub ThisDocument_SelectionChange(ByVal sender As Object, ByVal e As Microsoft.Office. _
Tools.Word.SelectionEventArgs)
System.Windows.Forms.MessageBox.Show("The selection in the document has changed.")
End Sub