Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,049
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Creating a PivotTable w/o selecting data in an existing PivotTable Damian Excel Discussion (Misc queries) 6 November 2nd 07 04:44 PM
Deleting cell data without deleting formula Tom Hall Excel Discussion (Misc queries) 4 October 29th 06 04:07 PM
How does one get the PivotTable report info that feeds another PivotTable report? Toby Erkson[_3_] Excel Programming 0 December 14th 04 10:00 PM
PivotTable - PivotTable Field name is not valid - error! miker1999[_17_] Excel Programming 1 June 10th 04 10:30 AM
Deleting Hyphens or Dashes from multiple cells without deleting the remaining content rmaloy Excel Programming 5 February 9th 04 01:59 AM


All times are GMT +1. The time now is 11:05 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"