PivotCache.CommandType (Excel)

Returns or sets one of these XlCmdType constants: xlCmdCube, xlCmdDefault, xlCmdSql, or xlCmdTable. Possible return values are xlCmdCube - Contains a cube name for an OLAP data source, xlCmdDAX - Contains a Data Analysis Expressions (DAX) formula, xlCmdDefault - Contains command text that the OLE DB provider understands, xlCmdExcel - Contains an Excel formula, xlCmdList - Contains a pointer to list data, xlCmdSql - Contains an SQL statement, xlCmdTable - Contains a table name for accessing OLE DB data sources, xlCmdTableCollection - Contains the name of a table collection.

You can set the CommandType property only if the value of the QueryType property for the query table or PivotTable cache is xlOLEDBQuery. If the value of the CommandType property is xlCmdCube, you cannot change this value if there is a PivotTable report associated with the query table.


ActiveWorkbook.PivotCaches(1).CommandType = xlCmdCube