View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Mark Mark is offline
external usenet poster
 
Posts: 989
Default creating multiple pivots fails

Hi.

I wrote an add-in that retrieves numerous parameters, extracts data from the
database, and returns a PivotTable, with none of the fields set... just the
outline of it.

This works fine, for creation of a single pivot table. However, I put it in
a loop to retrieve information for numerous projects, and it's failing at
this line:

pvC.CreatePivotTable TableDestination:="", TableName:=pvName,
DefaultVersion:=xlPivotTableVersion10

pvC is my PivotCache, pvName is the name of the pivot table.

The loop creates a new workbook, so each pivot table is in it's own Excel
workbook.

The error that I get is:

Application-defined or object-defined error

but if I hit Debug, and then hit the continue button (without changing
anything), it works. However, on the next run of the loop, I get the same
error, with no chance to Debug/Continue, and it stops.

However, if I put a Breakpoint into the code at this point, and manually
press the continue button for each run through the loop, it doesn't fail.

So, it appears that something is conflicting in the memory. I'd tried
putting in a DoEvents line, but it has no effect.

Can someone suggest something else to try? Thanks.

mark