Filter out an Item from a Pivot Table using VBA with an OLAP Data Source

The following VBA code does not work as expected: PivotField.HiddenItemsList Property (Excel)

Sub UseHiddenItemsList() 

    ActiveSheet.PivotTables(1).PivotFields(1).HiddenItemsList = _ 
    Array("[Product].[All Products].[Food]", _ 
    "[Product].[All Products].[Drink]") 

End Sub

To properly use this you must use the CubeField Object and also set the IncludeNewItemsInFilter to True


Sub HideSomeItems()
  With ActiveSheet.PivotTables(1).PivotFields("[SomeSource].[SomeHierarchy].[SomeField]")
  .ClearAllFilters 'Clear All The Filters
  .CubeField.IncludeNewItemsInFilter = True ' Enable this so that HiddenItemsList works
  .HiddenItemsList = Array("[SomeSource].[SomeHierarchy].[SomeField].[SomeItem].&ItemName")
 End With
End Sub