Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Deleting a PivotTable.
create a pivot table just fine Application.ActiveWorkbook.PivotCaches().Create(Ex cel.XlPivotTableSourceType.xlDatabase, sourceTableName, Excel.XlPivotTableVersionList.xlPivotTableVersion1 2).CreatePivotTable(destinationSheet.Cells[1, 1], pivotTableName, missing, Excel.XlPivotTableVersionList.xlPivotTableVersion1 2); but when I try to create another pivot table with the same name I get an error: Exception from HRESULT: 0x800A03EC ************** Exception Text ************** System.Runtime.InteropServices.COMException (0x800A03EC): Exception from HRESULT: 0x800A03EC Server stack trace: Exception rethrown at [0]: at System.Runtime.Remoting.Proxies.RealProxy.HandleRe turnMessage(IMessage reqMsg, IMessage retMsg) at System.Runtime.Remoting.Proxies.RealProxy.PrivateI nvoke(MessageData& msgData, Int32 type) at Microsoft.Office.Interop.Excel.PivotCache.CreatePi votTable(Object TableDestination, Object TableName, Object ReadData, Object DefaultVersion) at OrderHistory.ThisWorkbook.OutOfStockPivotTable(Str ing sourceTableName, Worksheet destinationSheet, String pivotTableName) in I suspect that I need to delete the former pivot table before I create a new table with the same name but I don't see how to delete/remove a pivoit table. Like I said that is what I "suspect" as being the cause of the error. Any suggestions? THank you. Kevin |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Deleting a PivotTable.
run this on the sheet before you create the pivot...pass the worksheet to it
... sub deleteAny(sh as worksheet) Dim pt As PivotTable For Each pt In sh.PivotTables pt.TableRange2.Delete Next end sub "Kevin Burton" wrote in message ... create a pivot table just fine Application.ActiveWorkbook.PivotCaches().Create(Ex cel.XlPivotTableSourceType.xlDatabase, sourceTableName, Excel.XlPivotTableVersionList.xlPivotTableVersion1 2).CreatePivotTable(destinationSheet.Cells[1, 1], pivotTableName, missing, Excel.XlPivotTableVersionList.xlPivotTableVersion1 2); but when I try to create another pivot table with the same name I get an error: Exception from HRESULT: 0x800A03EC ************** Exception Text ************** System.Runtime.InteropServices.COMException (0x800A03EC): Exception from HRESULT: 0x800A03EC Server stack trace: Exception rethrown at [0]: at System.Runtime.Remoting.Proxies.RealProxy.HandleRe turnMessage(IMessage reqMsg, IMessage retMsg) at System.Runtime.Remoting.Proxies.RealProxy.PrivateI nvoke(MessageData& msgData, Int32 type) at Microsoft.Office.Interop.Excel.PivotCache.CreatePi votTable(Object TableDestination, Object TableName, Object ReadData, Object DefaultVersion) at OrderHistory.ThisWorkbook.OutOfStockPivotTable(Str ing sourceTableName, Worksheet destinationSheet, String pivotTableName) in I suspect that I need to delete the former pivot table before I create a new table with the same name but I don't see how to delete/remove a pivoit table. Like I said that is what I "suspect" as being the cause of the error. Any suggestions? THank you. Kevin |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Creating a PivotTable w/o selecting data in an existing PivotTable | Excel Discussion (Misc queries) | |||
Deleting cell data without deleting formula | Excel Discussion (Misc queries) | |||
How does one get the PivotTable report info that feeds another PivotTable report? | Excel Programming | |||
PivotTable - PivotTable Field name is not valid - error! | Excel Programming | |||
Deleting Hyphens or Dashes from multiple cells without deleting the remaining content | Excel Programming |