PivotField.AddPageItem 方法 (Excel)

向具有多个项的页面字段添加其他项。

语法

表达式AddPageItem (ItemClearList)

表达 一个代表 PivotField 对象的变量。

参数

名称 必需/可选 数据类型 说明
Item 必需 字符串 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

支持和反馈

有关于 Office VBA 或本文档的疑问或反馈? 请参阅 Office VBA 支持和反馈,获取有关如何接收支持和提供反馈的指南。