PC Review


Reply
Thread Tools Rate Thread

Deleting a PivotTable.

 
 
Kevin Burton
Guest
Posts: n/a
 
      9th Jul 2009

create a pivot table just fine



Application.ActiveWorkbook.PivotCaches().Create(Excel.XlPivotTableSourceType.xlDatabase,
sourceTableName,

Excel.XlPivotTableVersionList.xlPivotTableVersion12).CreatePivotTable(destinationSheet.Cells[1, 1],

pivotTableName,

missing,


Excel.XlPivotTableVersionList.xlPivotTableVersion12);



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.HandleReturnMessage(IMessage
reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData&
msgData, Int32 type)
at Microsoft.Office.Interop.Excel.PivotCache.CreatePivotTable(Object
TableDestination, Object TableName, Object ReadData, Object DefaultVersion)
at OrderHistory.ThisWorkbook.OutOfStockPivotTable(String 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 With Quote
 
 
 
 
Patrick Molloy
Guest
Posts: n/a
 
      11th Jul 2009
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" <(E-Mail Removed)> wrote in message
news:F8AD63CF-C4C6-4275-9CD6-(E-Mail Removed)...
> create a pivot table just fine
>
>
>
> Application.ActiveWorkbook.PivotCaches().Create(Excel.XlPivotTableSourceType.xlDatabase,
> sourceTableName,
>
> Excel.XlPivotTableVersionList.xlPivotTableVersion12).CreatePivotTable(destinationSheet.Cells[1,
> 1],
>
> pivotTableName,
>
> missing,
>
>
> Excel.XlPivotTableVersionList.xlPivotTableVersion12);
>
>
>
> 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.HandleReturnMessage(IMessage
> reqMsg, IMessage retMsg)
> at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData&
> msgData, Int32 type)
> at Microsoft.Office.Interop.Excel.PivotCache.CreatePivotTable(Object
> TableDestination, Object TableName, Object ReadData, Object
> DefaultVersion)
> at OrderHistory.ThisWorkbook.OutOfStockPivotTable(String
> 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 With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
PivotTable total columns are blank. Can I make report based on PivotTable query? Song Su Microsoft Access Reports 0 6th Apr 2008 03:10 AM
Creating a PivotTable w/o selecting data in an existing PivotTable =?Utf-8?B?RGFtaWFu?= Microsoft Excel Misc 6 2nd Nov 2007 04:44 PM
How to get the PivotTable report info that feeds another PivotTable report. Toby Erkson Microsoft Excel Discussion 2 29th Dec 2004 03:03 PM
How does one get the PivotTable report info that feeds another PivotTable report? Toby Erkson Microsoft Excel Programming 0 14th Dec 2004 10:00 PM
PivotTable - PivotTable Field name is not valid - error! miker1999 Microsoft Excel Programming 1 10th Jun 2004 10:30 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:22 PM.