none
Excel 2003 + VBA + while giving font color to a text in RGB format

    Question

  • Hi,

    I am using Excel 2003. I am doing VBA code development to format the excel sheets.

    While trying to give font color in a cell text usng the code

    Range(CStr(x(i).childNodes.Item(k).Attributes.getNamedItem("reference").Text)).Select
    the value for CStr(x(i).childNodes.Item(k).Attributes.getNamedItem("reference").Text) is "A:A          

    With Selection.Font

    .Color = CStr(x(i).childNodes.Item(k).childNodes.Item(0).Attributes.getNamedItem("color").Text)

    the value for CStr(x(i).childNodes.Item(k).childNodes.Item(0).Attributes.getNamedItem("color").Text) is RGB(255,0,0)

    But it is throwing an error "Unable to set the color property of the font class" Run time error 1004

    Please share your ideas on this

    Regards,

    Sivakumar IRIAD

    Wednesday, September 29, 2010 2:02 PM

Answers

All replies

  • The color property needs to be set to the result of RGB(255,0,0), currently you are assign the text "RGB(255,0,0)".

    You need to write a function to extract the Red, Green and Blue values from the text and use them in the RGB function.


    Cheers,

    Andy
    www.andypope.info

    Wednesday, September 29, 2010 3:19 PM
  • Superb.....I got it and My issue got resolved...Thanks you very much ...

     

    Sivakumar IRIAD

     

    Friday, October 01, 2010 11:13 AM