向具有多个项的页面字段添加其他项。
expression.AddPageItem(Item, ClearList)
expression 必需。该表达式返回“应用于”列表中的对象之一。
Item String 类型,必需。PivotItem 对象的源名称,该名称与特定的联机分析处理 (OLAP) 成员的唯一名称相对应。
ClearList Variant 类型,可选。如果该值为 False(默认值),则向原有列表中添加一个页面项。如果该值为 True,则删除当前所有的项,然后添加 Item。
为了避免在运行时出现错误,数据源必须是 OLAP 源,选择的字段当前必须位于页面中,EnableMultiplePageItems 属性的值必须设置为 True。
在本例中,Microsoft Excel 添加一个源名称为“[Product].[All Products].[Food].[Eggs]”的页面项。本示例假定 OLAP 数据透视表位于活动工作表上。
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