Excel) (PivotField.AddPageItem 方法

會新增額外項目至多項目頁面欄位中。

語法

運算式AddPageItem (ItemClearList)

表達 代表 PivotField 物件的 變數。

參數

名稱 必要/選用 資料類型 描述
項目 必要 字串 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 支援與意見反應