C# VSTO: Coloring pivottable cells
- by tomboz
HI, I'm trying to make some code color a PivotTable.
It works just fine coloring the cells it's supposed to, but if I refresh the table, all the colors disappear, as if the colors haven't been properly attached to the PivotTable.
I have the following code (this is a snip from a larger code):
myPivotTable.PivotSelect("'" + item["Name"].ToString() + "'[All;Total]", XlPTSelectionMode.xlDataAndLabel, true);
((Range)Globals.ThisWorkbook.Application.Selection).Interior.Color = 15962653;
I've tried doing a macro in Excel in VB, and when it runs, it work works perfectly, so I don't understand why the C# VSTO won't work...
ActiveSheet.PivotTables("PivotTable1").PivotSelect "'ItemName'[All;Total]", xlDataAndLabel, True
Selection.Interior.Color = 15962653
Help is much appreciated :)