I am trying (mostly successfully) to \"read\" the colors from the active ThemeColorScheme
.
The subroutine below will obtain 12 colors from the theme,
Based on the above solution with HSL values adding here a demo that works in Excel. Works in conjunction with the above listed HSL solution.
Sub DemoExcelThemecolorsHSL()
Dim rng As Range
Dim n As Integer, m As Integer
Dim arrNames
Dim arrDescriptions
Dim arrValues
Dim schemeColors As ThemeColorScheme
Dim dblTintShade As Double
Dim lngColorRGB As Long, lngColorRGBshaded As Long
Dim ColorHSL As HSL, ColorHSLshaded As HSL
Set schemeColors = ActiveWorkbook.Theme.ThemeColorScheme
arrNames = Array("xlThemeColorDark1", "xlThemeColorLight1", "xlThemeColorDark2", "xlThemeColorLight2", "xlThemeColorAccent1", "xlThemeColorAccent2", _
"xlThemeColorAccent3", "xlThemeColorAccent4", "xlThemeColorAccent5", "xlThemeColorAccent6", "xlThemeColorHyperlink", "xlThemeColorFollowedHyperlink")
arrDescriptions = Array("Dark1", "Light1", "Dark2", "Light2", "Accent1", "Accent2", "Accent3", "Accent4", "Accent5", "Accent6", "Hyperlink", "Followed hyperlink")
arrValues = Array(2, 1, 4, 3, 5, 6, 7, 8, 9, 10, 11, 12)
' New sheet, title row
ActiveWorkbook.Worksheets.Add
Set rng = Cells(1, 2)
rng(1, 1).Value2 = "ThemeColor Name"
rng(1, 2).Value2 = "Value"
rng(1, 3).Value2 = "Description"
rng(1, 4).Value2 = "TintAndShade"
rng.Resize(1, 4).Font.Bold = True
Set rng = rng(3, 1)
' color matrix
For n = 0 To 11
rng(n * 2, 1).Value = arrNames(n)
rng(n * 2, 2).Value = arrValues(n)
rng(n * 2, 3).Value = arrDescriptions(n)
lngColorRGB = schemeColors(n + 1).RGB
For m = 0 To 5
ColorHSL = RGBtoHSL(lngColorRGB)
dblTintShade = SelectTintOrShade(ColorHSL, m)
ColorHSLshaded = ApplyTintAndShade(ColorHSL, dblTintShade)
lngColorRGBshaded = HSLtoRGB(ColorHSLshaded)
With rng(n * 2, m + 4)
.Value = dblTintShade
If ColorHSLshaded.L < 0.5 Then .Font.ColorIndex = 2
' fixed color, not changing when a new Color scheme is being selected
.Interior.color = lngColorRGBshaded
' cell color dependent on selected color palette
.Offset(1, 0).Interior.ThemeColor = arrValues(n)
.Offset(1, 0).Interior.TintAndShade = dblTintShade
End With
Next m
Next n
rng.Resize(1, 3).EntireColumn.AutoFit
End Sub