AddPageItem Method

Microsoft Excel Visual Basic

Show All

AddPageItem Method

       

Adds an additional item to a multiple item page field.

expression.AddPageItem(Item, ClearList)

expression   Required. An expression that returns one of the objects in the Applies To list.

Item  Required String.  Source name of a PivotItem object, corresponding to the specific Online Analytical Processing (OLAP) member unique name.

ClearList  Optional Variant. If False (default), adds a page item to the existing list. If True, deletes all current items and adds Item.

Remarks

To avoid run-time errors, the data source must be an OLAP source, the field chosen must currently be in the page position, and the EnableMultiplePageItems property must be set to True.

Example

In this example, Microsoft Excel adds a page item with a source name titled "[Product].[All Products].[Food].[Eggs]". This example assumes an OLAP PivotTable exists on the active worksheet.

Sub UseAddPageItem()

    ' The source is an OLAP database and you can manually reorder items.
    ActiveSheet.PivotTables(1).CubeFields("[Product]"). _
        EnableMultiplePageItems = True

    ' Add the page item titled "[Product].[All Products].[Food].[Eggs]".
    ActiveSheet.PivotTables(1).PivotFields("[Product]").AddPageItem ( _
        "[Product].[All Products].[Food].[Eggs]")

End Sub