Trouble applying a style to a range

I have this code which will loop every 12 rows and apply a particular
style to a group of 6 rows. Below is the code that I think should do
the job but doesn’t. Any suggestions?



Dim leftpoint As Integer = 3

Dim rightpoint As Integer = 8



Dim style As Style = xlApp.Styles(xlApp.Styles.Add)

style.Pattern = BackgroundType.Solid

style.BackgroundColor = Drawing.Color.FromArgb(40)



Do

If rightpoint > 4467 Then

Exit Do

Else

Dim rng As Range = xlWSheet.Cells.CreateRange(“F” &
leftpoint.ToString, _

“S” & rightpoint.ToString)

rng.Style = style



'.Interior.ColorIndex = 40

'.Style.Pattern = BackgroundType.Solid



leftpoint = leftpoint + 12

rightpoint = rightpoint + 12

End If

Loop

What's the problem? Is the color not correct?

Please try:

excel.ChangePalette(Drawing.Color.FromArgb(40), 55)

Dim leftpoint As Integer = 3
Dim rightpoint As Integer = 8

Dim style As Style = xlApp.Styles(xlApp.Styles.Add)
style.Pattern = BackgroundType.Solid
style.ForegroundColor = Drawing.Color.FromArgb(40)

Do
If rightpoint > 4467 Then
Exit Do
Else
Dim rng As Range = xlWSheet.Cells.CreateRange("F" & leftpoint.ToString, _
"S" & rightpoint.ToString)
rng.Style = style

leftpoint = leftpoint + 12
rightpoint = rightpoint + 12
End If
Loop

whenever i apply style.ForegroundColor = Drawing.Color.*

to a color besides Gray or Black, it fills the range with the color black.

If you set a Color.Red, does it still show black?

Please check Color and Palette for reference.