Reputation: 364
I'm developing a vsto addin for Excel, and I'm trying to change the color to the comments in Excel.
This is the code that I have:
Excel.Range activeCell = _application.ActiveCell;
activeCell.AddComment("some text"));
activeCell.Comment.Shape.Fill.BackColor = Color.Red;
The exception I'm getting is:
Cannot implicitly convert type 'System.Drawing.Color' to 'Microsoft.Office.Interop.Excel.ColorFormat'
I cannot find how to make a conversion between the two formats.
Upvotes: 2
Views: 2866
Reputation: 39
Try this:
activeCell.Comment.Shape.Fill.BackColor = XlRgbColor.rgbRed;
Or this(EDIT: False):
activeCell.Comment.Shape.Fill.BackColor.RGB = Color.FromRgb(255,0,0);
Upvotes: 0
Reputation: 16956
One option is to use ColorTranslator.ToOle
int oleColor = ColorTranslator.ToOle(Color.Red);
activeCell.Comment.Shape.Fill.BackColor.RGB = oleColor;
Upvotes: 6