VB.NET - How to change Excel's cell color

Asked By Seo-Young Noh on 29-Jul-05 12:29 PM
Dear all,


I am using VB.NET. I want to change excel's cell color. I create a style as follows:

 Dim HeaderStyle As Excel.Style = gExcelBook.Styles.Add("HeaderStyle")
        With HeaderStyle
            .Font.Name = "Tahoma"
            .Font.Size = 11
            .Font.Color = Color.Blue
            .Font.Bold = True
            .HorizontalAlignment = Excel.XlHAlign.xlHAlignCenter
        End With

My problem is that Font.Color = Color.Blue causes a run time error such as "Type mismatch."!
Do you have any idea for this?

Thanks.

Seo-Young

Try using this

Asked By ashwin gaddam on 29-Jul-05 12:34 PM
Color = RGB(255, 0, 0)
To set the color

Thanks

Asked By Seo-Young Noh on 29-Jul-05 12:45 PM
It works!
Aks C replied to ashwin gaddam on 18-Dec-10 07:53 PM
i m not getting how to use Color=RGB(255,0,0)

i want to change the color of specific cell
and i am using foll code, but its not working. Can you help me out??

.Cells.Range(p, 6).Interior.Color = Color.Green