Compartilhar via


SlicerCaches.Add Method

Adds a new SlicerCache object to the collection.

Namespace:  Microsoft.Office.Interop.Excel
Assembly:  Microsoft.Office.Interop.Excel (in Microsoft.Office.Interop.Excel.dll)

Syntax

'Declaration
Function Add ( _
    Source As Object, _
    SourceField As Object, _
    Name As Object _
) As SlicerCache
'Usage
Dim instance As SlicerCaches
Dim Source As Object
Dim SourceField As Object
Dim Name As Object
Dim returnValue As SlicerCache

returnValue = instance.Add(Source, SourceField, _
    Name)
SlicerCache Add(
    Object Source,
    Object SourceField,
    Object Name
)

Parameters

  • SourceField
    Type: System.Object

    The name of the field in the data source to filter by.

  • Name
    Type: System.Object

    The name Excel uses to reference the slicer cache (the value of the Name property).

Return Value

Type: Microsoft.Office.Interop.Excel.SlicerCache
Returns SlicerCache.

Remarks

The Source parameter can be a WorkbookConnection object, a PivotTable object, or a string. If a PivotTable object is passed, the associated PivotCache object is used as the data source. If a string is passed, it is interpreted as the name of a WorkbookConnection object, and if no such WorkbookConnection object exists, a run-time error is generated.

When specifying the SourceField parameter, for non-OLAP data sources, use the PivotField object from the PivotCache object that the slicer is based on, or the unique name of that object (the value of the Name property). For OLAP data sources, use the MDX unique name of the hierarchy that the SlicerCache is based on. You can also specify a level of the OLAP hierarchy, and Excel will use the corresponding hierarchy.

If the Name parameter is omitted, Excel will generate a name. By default, Excel concatenates "Slicer_" with the value of the Caption property for slicers with non-OLAP data sources, or with the value of the Caption property for slicers with OLAP data sources. (Replacing any spaces with "_".) If required to make the name unique in the workbook namespace, Excel adds an integer to the end of the generated name. If you specify a name that already exists in the workbook namespace, the Add(Object, Object, Object) method will fail.

See Also

Reference

SlicerCaches Interface

SlicerCaches Members

Microsoft.Office.Interop.Excel Namespace