它是一個自定義圖表模板?如果是這樣,您可以爲模板定製RGB值的自定義列表。
否則,您可能只是使用工作簿主題的默認顏色。
此代碼將六種默認工作簿主題顏色重新應用於圖表。如果有超過六個系列,主題顏色重複。 Excel也改變了後續六個系列的亮度,但我沒有打擾過。如果你需要調整亮度,我可以回來執行它。
Sub ReapplyDefaultColors()
Dim iSrs As Long, nSrs As Long
Dim iThemeColor As MsoThemeColorIndex
If ActiveChart Is Nothing Then
MsgBox "Select a chart and try again.", vbExclamation, "No Active Chart"
Else
iThemeColor = msoThemeColorAccent1
With ActiveChart
nSrs = .SeriesCollection.Count
For iSrs = 1 To nSrs
.SeriesCollection(iSrs).Format.Fill.ForeColor.ObjectThemeColor = _
iThemeColor
iThemeColor = iThemeColor + 1 ' msoThemeColorAccent2, 3, 4, etc.
If iThemeColor > msoThemeColorAccent6 Then
' recycle colors
' should also adjust brightness
iThemeColor = msoThemeColorAccent1
End If
Next
End With
End If
End Sub
編輯:事實證明,我們可以使用已棄用,但仍從Excel 2003年的工作語法重新應用自動格式化圖表系列:
Sub ReapplyDefaultColors()
Dim iSrs As Long, nSrs As Long
If ActiveChart Is Nothing Then
MsgBox "Select a chart and try again.", vbExclamation, "No Active Chart"
Else
With ActiveChart
nSrs = .SeriesCollection.Count
For iSrs = 1 To nSrs
.SeriesCollection(iSrs).Interior.ColorIndex = xlAutomatic
Next
End With
End If
End Sub
這不是自動。 –