如何在Excel VBA中用英文术语选择指定主题色而无需RGB值
Great question! That specific color isn’t part of VBA’s standard named color constants (like vbBlue), but you don’t need to mess with RGB values to use it. It’s a theme color variant, and Excel’s VBA object model lets you reference it directly using the built-in theme color system.
Here’s how to make it work:
Step 1: Target the Base Theme Color
"Dark Blue, Text 2" corresponds to the msoThemeColorText2 constant in VBA—this is the core theme color your 25% darker variant is derived from.
Step 2: Apply the Darker Modifier
The "25% Darker" adjustment is handled by the TintAndShade property:
- Negative values darken the color (use
-0.25for exactly 25% darker) - Positive values lighten the color
Example Code Snippets
To set a cell’s fill color to your target shade:
' Apply "Dark Blue, Text 2, 25% Darker" to cell A1's interior With Range("A1").Interior .ThemeColor = msoThemeColorText2 .TintAndShade = -0.25 End With
To apply the color to cell text:
' Apply the color to cell A1's font With Range("A1").Font .ThemeColor = msoThemeColorText2 .TintAndShade = -0.25 End With
This method uses Excel’s native theme system, so it’ll even adapt if you later change the workbook’s overall theme (the 25% darker variant stays relative to the base Text 2 color). No manual RGB calculations needed!
内容的提问来源于stack exchange,提问作者Maury Markowitz

