只要添加或删除指定数据透视表视图中的字段、字段集或汇总,该事件就会发生。
Private Sub Form_PivotTableChange(ByVal Reason As Long)
Reason 指定数据透视表列表如何更改。可以是 PivotTableReasonEnum 常量之一。
plPivotTableReasonTotalAdded |
plPivotTableReasonFieldSetAdded |
plPivotTableReasonFieldAdded |
下面的示例说明了捕获 PivotTableChange 事件的子程序的语法。为使该示例奏效,必须设置一个对 Microsoft Office Web Components 10.0 类型库的引用。
Private Sub Form_PivotTableChange(Reason As Long)
Select Case Reason
Case OWC.plPivotTableReasonTotalAdded
MsgBox "A total was added!"
Case OWC.plPivotTableReasonFieldSetAdded
MsgBox "A field set was added!"
Case OWC.plPivotTableReasonFieldAdded
MsgBox "A field was added!"
End Select
End Sub