I have an Excel spreadsheet with four pivot tables and each has a related chart. Using VB.Net I update the Data Source which updates the pivot tables which automatically updates their related charts. All this works great. But now I have to update the title in each chart.
What I think I need to do is access the charts by knowing the name of their related pivot table.
I tried looping through worksheet.pivotTables to get each PivotTable name but get an error at the For Each line:
For Each xlPivotTable As Excel.PivotTable In xlWorkSheetShippedSQ.PivotTables
strCurrentPivotTable = xlPivotTable.Name
Next
At xlWorkSheetShippedSQ.PivotTables it displays
implicit conversion from object to ienumerable
and wants me to use CType(xlWorkSheetShippedSQ.PivotTables, IEnumerable(Of Excel.PivotTable))
but when I do this I get an InvalidCastException. xlWorkSheetShippedSQ is the current worksheet and I've successfully used it in other places.
Is there a way to access each chart to change each name? if so please share how?
PivotTables
is a function that returns one of two types. Select the proper type. – TnTinMn