views:

16

answers:

0

Hi,

I'm trying to delete all charts that a linked to a specific PivotTable.

My code is really simple, but I can't figure out how to test if the found chart's datasource is the given PivotTable's data.

public void DeleteCharts(Worksheet mySheet, PivotTable myPT)
    {
        // Delete all charts
        foreach (ChartObject item in (ChartObjects)mySheet.ChartObjects(Type.Missing))
        {
            if(item.Chart == myPT)
            {
                item.Delete();
            }
        }
    }

I know the item.Chart == myPT is bogus, but it's just to illustrate what I want to do.