Format Shape With ThemeColors

R

Roger

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
 
A

AdamV

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top