CommandBeforeExecute Event

Microsoft Office Web Components Visual Basic

Private Sub object_CommandBeforeExecute (ByVal Command As Variant, ByVal Cancel As ByRef)

object    A ChartSpace , PivotTable , or Spreadsheet object.

Command Required. The command that has been executed.

Cancel Required. Set the Value property of this object to True to cancel the command.

Remarks

The OCCommandId, ChartCommandIdEnum, PivotCommandId, and SpreadsheetCommandId constants contain lists of the supported commands for each of the Microsoft Office Web Components.

Example

This example refreshes PivotTable1 when the export command is invoked so that the latest data is exported to Microsoft Excel.

Sub PivotTable1_CommandBeforeExecute(Command, Cancel)

   Dim ptConstants

   Set ptConstants = PivotTable1.Constants

   ' Check to see if the Export command
   ' has been invoked.
   If Command = ptConstants.plCommandExport Then

       ' Refresh the PivotTable list.
       PivotTable1.Refresh

   End If

End Sub