ActiveObject Property

Microsoft Office Web Components Visual Basic

expression.ActiveObject

expression    Required. An expression that returns a PivotTable object.

Remarks

This property returns Nothing if no detail cells are selected.

Example

This example enables the editing of detail records in PivotTable1, then places the current date in the selected detail cell. The editing of detail records is disallowed once the date has been inserted into the selected cell.

Sub EditSelectedCell()

    Dim objActiveCell

    ' Allow editing of detail records.
    PivotTable1.ActiveView.AllowEdits = True

    ' Set a variable to the currently selected cell.
    Set objActiveCell = PivotTable1.ActiveObject

    ' Check whether a detail cell is selected.
    If Not objActiveCell Is Nothing Then

        ' Set the value of the detail cell
        ' to the current date.
        ' Note: This will result in a run-time
        ' error if the data type of the selected
        ' cell does not support date values.
        objActiveCell.Value = Date

    End If

    ' Disallow editing of detail records.
    PivotTable1.ActiveView.AllowEdits = False

End Sub