D
DuncanL
Why is Excel ignoring my custom colours for chart lines and fills, and
picking something a bit (but not very) similar instead? Sea green is blue,
lavender becomes grey...
This example has been cobbled together using an MS TechNet example
-------------------------------------------------------------------
Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = True
Set objWorkbook = objExcel.Workbooks.Add()
Set objWorksheet = objWorkbook.Worksheets(1)
objWorksheet.Cells(1,1) = "Operating System"
objWorksheet.Cells(2,1) = "Windows Server 2003"
objWorksheet.Cells(3,1) = "Windows XP"
objWorksheet.Cells(4,1) = "Windows 2000"
objWorksheet.Cells(1,2) = "Number of Computers"
objWorksheet.Cells(2,2) = 545
objWorksheet.Cells(3,2) = 987
objWorksheet.Cells(4,2) = 611
objWorksheet.Cells(1,3) = "Something Else"
objWorksheet.Cells(2,3) = 432
objWorksheet.Cells(3,3) = 278
objWorksheet.Cells(4,3) = 495
objWorksheet.Cells(1,4) = "Another thing"
objWorksheet.Cells(2,4) = 832
objWorksheet.Cells(3,4) = 458
objWorksheet.Cells(4,4) = 921
Set objRange = objWorksheet.UsedRange
objRange.Select
Set colCharts = objExcel.Charts
colCharts.Add()
With objExcel.ActiveChart
..ChartType = -4100
..SeriesCollection(1).Interior.Color = RGB(144, 211, 199)
..SeriesCollection(1).Border.Color = RGB(93, 191, 173)
..SeriesCollection(1).Border.Weight = 4
..SeriesCollection(2).Interior.Color = RGB(190, 186, 218)
..SeriesCollection(2).Border.Color = RGB(140, 133, 190)
..SeriesCollection(2).Border.Weight = 4
..SeriesCollection(3).Interior.Color = RGB(251, 128, 114)
..SeriesCollection(3).Border.Color = RGB(249, 64, 43)
..SeriesCollection(3).Border.Weight = 4
End With
-------------------------------------------------------------------
The following (rubbish) HTML saved as a file will show the colours I expect:
-------------------------------------------------------------------
<html>
<body>
<p style="width:100%;margin:0;padding:0;background-color:RGB(144, 211,
199);"> </p>
<p style="width:100%;margin:0;padding:0;background-color:RGB(93, 191,
173);"> </p>
<p style="width:100%;margin:0;padding:0;background-color:RGB(190, 186,
218)"> </p>
<p style="width:100%;margin:0;padding:0;background-color:RGB(140, 133,
190)"> </p>
<p style="width:100%;margin:0;padding:0;background-color:RGB(251, 128,
114)"> </p>
<p style="width:100%;margin:0;padding:0;background-color:RGB(249, 64,
43)"> </p>
</body>
</html>
picking something a bit (but not very) similar instead? Sea green is blue,
lavender becomes grey...
This example has been cobbled together using an MS TechNet example
-------------------------------------------------------------------
Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = True
Set objWorkbook = objExcel.Workbooks.Add()
Set objWorksheet = objWorkbook.Worksheets(1)
objWorksheet.Cells(1,1) = "Operating System"
objWorksheet.Cells(2,1) = "Windows Server 2003"
objWorksheet.Cells(3,1) = "Windows XP"
objWorksheet.Cells(4,1) = "Windows 2000"
objWorksheet.Cells(1,2) = "Number of Computers"
objWorksheet.Cells(2,2) = 545
objWorksheet.Cells(3,2) = 987
objWorksheet.Cells(4,2) = 611
objWorksheet.Cells(1,3) = "Something Else"
objWorksheet.Cells(2,3) = 432
objWorksheet.Cells(3,3) = 278
objWorksheet.Cells(4,3) = 495
objWorksheet.Cells(1,4) = "Another thing"
objWorksheet.Cells(2,4) = 832
objWorksheet.Cells(3,4) = 458
objWorksheet.Cells(4,4) = 921
Set objRange = objWorksheet.UsedRange
objRange.Select
Set colCharts = objExcel.Charts
colCharts.Add()
With objExcel.ActiveChart
..ChartType = -4100
..SeriesCollection(1).Interior.Color = RGB(144, 211, 199)
..SeriesCollection(1).Border.Color = RGB(93, 191, 173)
..SeriesCollection(1).Border.Weight = 4
..SeriesCollection(2).Interior.Color = RGB(190, 186, 218)
..SeriesCollection(2).Border.Color = RGB(140, 133, 190)
..SeriesCollection(2).Border.Weight = 4
..SeriesCollection(3).Interior.Color = RGB(251, 128, 114)
..SeriesCollection(3).Border.Color = RGB(249, 64, 43)
..SeriesCollection(3).Border.Weight = 4
End With
-------------------------------------------------------------------
The following (rubbish) HTML saved as a file will show the colours I expect:
-------------------------------------------------------------------
<html>
<body>
<p style="width:100%;margin:0;padding:0;background-color:RGB(144, 211,
199);"> </p>
<p style="width:100%;margin:0;padding:0;background-color:RGB(93, 191,
173);"> </p>
<p style="width:100%;margin:0;padding:0;background-color:RGB(190, 186,
218)"> </p>
<p style="width:100%;margin:0;padding:0;background-color:RGB(140, 133,
190)"> </p>
<p style="width:100%;margin:0;padding:0;background-color:RGB(251, 128,
114)"> </p>
<p style="width:100%;margin:0;padding:0;background-color:RGB(249, 64,
43)"> </p>
</body>
</html>