I am trying to refresh a pivot table in an Excel sheet and get the following exception:
Item method in the PivotTables class failed
Heres t
Assuming the indexing starts at zero you will overrun the collection with your loop.
Try:
for (int i = 0; i < pivotTablesCount; i++)
If that doesn't work Excel probably starts indexing at 1 not at 0.
for (int i = 1; i <= pivotTablesCount; i++)