Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default 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"

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default 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
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default 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



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Unable to get the Interior property of the PlotArea class [email protected] Charts and Charting in Excel 2 September 3rd 08 03:41 PM
"Unable to set the Formula property of the Series class" with a tw PeterQ Charts and Charting in Excel 1 February 15th 06 07:37 PM
unable to get the Interior property of the range class joe Excel Programming 4 December 1st 05 12:14 AM
"Unable to get the Pivotfieldsd property of the Pivot Class" twaccess[_21_] Excel Programming 1 July 8th 05 01:42 PM
Unable to set the colorIndex Property of the Interior Class Error GriffyGriff Excel Programming 3 October 3rd 03 04:37 PM


All times are GMT +1. The time now is 01:41 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"