Interop - "Unable to set the Color property of the Interior class"
Hello! I am begging for your help...
I am using the Excel interop (Microsoft Excel 11.0 Object Library, version 1.5.0.0) to open an existing workbook and adding conditional formats to certain cells to mimic "hidding" them. I keep receiving exceptions from the "Microsoft Office Excel" interop to the effect that I cannot set the font's color and the interior's color. If you know, could you please reply to this posting? Thanks! The C# code is as follows: conditionalFormat = conditionalFormats.Add(Excel.XlFormatConditionType .xlExpression , System.Reflection.Missing.Value , (object)formulas.ToString(), System.Reflection.Missing.Value); conditionalFormat.Font.Color = 0xff00; // triggers the "Unable to set the Color property of the Font class" conditionalFormat.Interior.Color = 0xff00; // triggers the "Unable to set the Color property of the Interior class" // conditionalFormat.Font.ColorIndex = 19; Triggers the "Unable to set the ColorIndex property of the Font class" // conditionalFormat.Interior.ColorIndex = 19; Triggers the "Unable to set the ColorIndex property of the Interior class" |
Interop - "Unable to set the Color property of the Interior class"
The reason of this error was that the worksheet was protected. I unprotected
it and now almost 70% of the conditional formats are successful. The ones that are problematic are those that have the inequality operator "<" along with a number, as in the following (the named range does exist, the thread is US): =OR((IF(ISBLANK(Q36540A4),0,Q36540A4))<0) Even if I use NOT to avoid using the <, as the following: =OR((NOT(IF(ISBLANK(Q36325A3),0,Q36325A3))=0)) I get an error "Exception from HRESULT: 0x800A03EC" with stack trace as follows: at System.RuntimeType.ForwardCallToInvokeMember(Strin g memberName, BindingFlags flags, Object target, Int32[] aWrapperTypes, MessageData& msgData) at Excel.FormatConditions.Add(XlFormatConditionType Type, Object Operator, Object Formula1, Object Formula2) at Gartner.Decm.BusinessLayer.ExportToExcel.CreateCel lHideCriteria(Range cellRange, StringBuilder formulas) in D:\Versioning\Aurora\trunk\DECMBusinessLogic\Utili ties\ExportToExcel.cs:line 1101 Also, would anybody know the translation from RGB to hexadecimal for color R 253, G 250, B 255? Many thanks for any information that you can provide. Elsa |
Interop - "Unable to set the Color property of the Interior class"
VB/VBA has the RGB() function to return a Long from the 3 components.
Couldn't tell you about C#. NickHK "Elsa" wrote in message ... The reason of this error was that the worksheet was protected. I unprotected it and now almost 70% of the conditional formats are successful. The ones that are problematic are those that have the inequality operator "<" along with a number, as in the following (the named range does exist, the thread is US): =OR((IF(ISBLANK(Q36540A4),0,Q36540A4))<0) Even if I use NOT to avoid using the <, as the following: =OR((NOT(IF(ISBLANK(Q36325A3),0,Q36325A3))=0)) I get an error "Exception from HRESULT: 0x800A03EC" with stack trace as follows: at System.RuntimeType.ForwardCallToInvokeMember(Strin g memberName, BindingFlags flags, Object target, Int32[] aWrapperTypes, MessageData& msgData) at Excel.FormatConditions.Add(XlFormatConditionType Type, Object Operator, Object Formula1, Object Formula2) at Gartner.Decm.BusinessLayer.ExportToExcel.CreateCel lHideCriteria(Range cellRange, StringBuilder formulas) in D:\Versioning\Aurora\trunk\DECMBusinessLogic\Utili ties\ExportToExcel.cs:line 1101 Also, would anybody know the translation from RGB to hexadecimal for color R 253, G 250, B 255? Many thanks for any information that you can provide. Elsa |
All times are GMT +1. The time now is 04:18 AM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com