ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   RGB fill colours (https://www.excelbanter.com/excel-programming/399632-rgb-fill-colours.html)

DuncanL

RGB fill colours
 
Any ideas why the chart fill won't accept RGB colour values? Despite MSDN
saying a FillFormat should....
http://msdn2.microsoft.com/en-us/lib...ffice.11).aspx

An example:

--------------------------------------------
bRGB = false
With oBook.ActiveChart.PlotArea.Fill

if (bRGB) then
' This doesn't work
.ForeColor.RGB = RGB(128, 0, 0)
.BackColor.RGB = RGB(170, 170, 170)
else
' This works
.ForeColor.SchemeColor = 15
.BackColor.SchemeColor = 16
end if

.TwoColorGradient msoGradientHorizontal, 1
End With
--------------------------------------------

Setting bRGB to true results in: Wrong number of arguments or invalid
property assignment: 'ForeColor.RGB'

This is being called from an external VBScript, not within Excel, if that
makes a difference.

Am I misreading how this should work? Suggestions or workarounds welcome.
Thanks.

Andy Pope

RGB fill colours
 
Hi,

The MSDN example is for Shapes not charts.
The RGB property for a chart element is readonly.

The help says:

RGB property as it applies to the ChartColorFormat object.
Returns the red-green-blue value of the specified color. Read-only Long.

Charts, unlike shapes, are restricted to the usual 56 colour palette of
excel.

Cheers
Andy
--

Andy Pope, Microsoft MVP - Excel
http://www.andypope.info
"DuncanL" wrote in message
...
Any ideas why the chart fill won't accept RGB colour values? Despite MSDN
saying a FillFormat should....
http://msdn2.microsoft.com/en-us/lib...ffice.11).aspx

An example:

--------------------------------------------
bRGB = false
With oBook.ActiveChart.PlotArea.Fill

if (bRGB) then
' This doesn't work
.ForeColor.RGB = RGB(128, 0, 0)
.BackColor.RGB = RGB(170, 170, 170)
else
' This works
.ForeColor.SchemeColor = 15
.BackColor.SchemeColor = 16
end if

.TwoColorGradient msoGradientHorizontal, 1
End With
--------------------------------------------

Setting bRGB to true results in: Wrong number of arguments or invalid
property assignment: 'ForeColor.RGB'

This is being called from an external VBScript, not within Excel, if
that
makes a difference.

Am I misreading how this should work? Suggestions or workarounds welcome.
Thanks.



DuncanL

RGB fill colours
 

The MSDN example is for Shapes not charts.
The RGB property for a chart element is readonly.


Ah... bother!

Thanks for the help.


Duncan


All times are GMT +1. The time now is 03:59 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com