My code is
Sub PieMarkers()
Dim chtMarker As Chart
Dim chtMain As Chart
Dim intPoint As Integer
Dim rngRow As Range
Dim lngPointIndex As Long
Dim thmColor As Long
Dim myTheme As String
Application.ScreenUpdating = False
Set chtMarker = ActiveSheet.ChartObjects("chtMarker").Chart
Set chtMain = ActiveSheet.ChartObjects("chtMain").Chart
Set chtMain = ActiveSheet.ChartObjects("chtMain").Chart
Set rngRow = Range(ThisWorkbook.Names("PieChartValues").RefersTo)
For Each rngRow In Range("PieChartValues").Rows
chtMarker.SeriesCollection(1).Values = rngRow
ThisWorkbook.Theme.ThemeColorScheme.Load GetColorScheme(thmColor)
chtMarker.Parent.CopyPicture xlScreen, xlPicture
lngPointIndex = lngPointIndex + 1
chtMain.SeriesCollection(1).Points(lngPointIndex).Paste
thmColor = thmColor + 1
Next
lngPointIndex = 0
Application.ScreenUpdating = True
End Sub
Function GetColorScheme(i As Long) As String
Const thmColor1 As String = "C:\Program Files\Microsoft Office\Document Themes 14\Theme Colors\Blue Green.xml"
Const thmColor2 As String = "C:\Program Files\Microsoft Office\Document Themes 14\Theme Colors\Orange Red.xml"
Select Case i
Case 0
GetColorScheme = thmColor1
Case 1
GetColorScheme = thmColor2
End Select
End Function
the code is meant to change the colour theme of successive pie charts which are used as bubbles in a bubble chart. So The function is just meant to select a colour scheme which I previously saved as a string and then to change it according to the run of the script so that the first pie has another colour than the next pie chart .... I do get an error message when debugging the code at the line
ThisWorkbook.Theme.ThemeColorScheme.Load GetColorScheme(thmColor)
the error message is runtime error 2147024809 saying the indicated value is out of range..can anybody help me what appears to be the problem here?
And would there be any way to integrate the display of the pie components (the name of the componetns which si indicated in the head of the column in each pie chart which is then transferred to the bubble chart?
SeriesCollection(1)
. But unless you have specific needs for specific colors, simply changing the Theme prior to the copy/paste should give you some variation. – David ZemensTheme.ThemeColorScheme
to the active workbook, which will change the appearance/color of the chart series. See my answer below. – David Zemens