ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Format Shape With ThemeColors (https://www.excelbanter.com/excel-discussion-misc-queries/250015-format-shape-themecolors.html)

Roger

Format Shape With ThemeColors
 
I can format shapes with RGB
ActiveSheet.Shapes("Test").Fill.ForeColor.RGB = RGB(128, 128, 128)
Is there a way to format a shape using themecolors in the same way you can
format a cell
With Range("A1").Interior
.ThemeColor = xlThemeColorAccent3
.TintAndShade = 0.799981688894314
End With
I have tried every variation of the code & syntax to no avail - could
someone give me an example of the code to do this please - thankyou in
anticipation

AdamV[_2_]

Format Shape With ThemeColors
 
This is the sort of syntax you are looking for:

ActiveSheet.Shapes.Range(Array("Test")).Select
With Selection.ShapeRange.Fill
.Visible = msoTrue
.ForeColor.ObjectThemeColor = msoThemeColorAccent3
.ForeColor.TintAndShade = 0.8
.Transparency = 0
.Solid
End With
With Selection.ShapeRange.Line
.Visible = msoTrue
.ForeColor.ObjectThemeColor = msoThemeColorAccent6
.ForeColor.TintAndShade = 0.4
.Transparency = 0
End With

You can drop things like transparency and solid if you won't need to
change them, but sometimes it is better to be sure (eg colours will look
wrong if the transparency is not 0).
For TintAndShade I tend to use rounded numbers, although they won't
exactly match the choices in the gallery (but it also means you have
easy access to a wider range if you want to, while remaining 'theme aware')

Hope this helps

Adam

Roger wrote:
I can format shapes with RGB
ActiveSheet.Shapes("Test").Fill.ForeColor.RGB = RGB(128, 128, 128)
Is there a way to format a shape using themecolors in the same way you can
format a cell
With Range("A1").Interior
.ThemeColor = xlThemeColorAccent3
.TintAndShade = 0.799981688894314
End With
I have tried every variation of the code & syntax to no avail - could
someone give me an example of the code to do this please - thankyou in
anticipation



All times are GMT +1. The time now is 05:41 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com