C# VSTO: Coloring pivottable cells

Posted by tomboz on Stack Overflow See other posts from Stack Overflow or by tomboz
Published on 2010-05-19T08:54:11Z Indexed on 2010/06/01 14:13 UTC
Read the original article Hit count: 479

Filed under:
|
|
|
|

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 :)

© Stack Overflow or respective owner

Related posts about c#

Related posts about excel