![]() |
|
#1
|
|||
|
|||
![]()
I like to set the color of a font in a paragraph style to an accentcolor (from the document theme).
On a range I can use: Selection.Font.Fill.ForeColor.ObjectThemeColor =wdThemeColorAccent2 however if I try to apply the color to a font in a style, I get an error 4680 (That property is not supported for this object) ActiveDocument.Styles(wdStyleHeading1).Font.Fill.F oreColor.ObjectThemeColor = wdThemeColorAccent2 I can set the color if I use ActiveDocument.Styles(wdStyleHeading1).Font.Color = ActiveDocument.DocumentTheme.ThemeColorScheme(msoT hemeAccent2) however it doesn't point to the position in the theme but uses it's RGB. That's not what I want. (Note that the .Color property of a font still works) Does anybody know how to archieve this? I was also wondering why I need the msoThemeAccent enum instead of the wdThemeColorAccent. I was under the impression that for Word objects I need the wdThemeColorAccent and for Office objects the msoThemeColor? |
#2
|
||||
|
||||
![]()
Try this instead
Code:
ActiveDocument.Styles(wdStyleHeading1).Font.Color = -721354753
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia |
#3
|
|||
|
|||
![]()
Thanks for your response.
This changes only the color. This is not what I want to archieve. I want to set the color to the relative position in the palet, not to a fixed value, so that when the theme is changed, the color in the style changes as well. |
#4
|
||||
|
||||
![]()
That number is for Accent2, not a fixed rgb value. Give it a try and I believe it will work on your machine the same as it does on mine
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia |
#5
|
|||
|
|||
![]()
Thank you so much!
You're right. That seems to do the trick. Can you tell me what this number is? Is it a value for a constant? Any place I can find the other numbers for the various accent colors? |
#6
|
|||
|
|||
![]()
The Word object model does not support setting the font color of a style to a theme color. The code below will generate an error if you try it.
Code:
ActiveDocument.Styles(wdStyleHeading1).Font.Fill.ForeColor.ObjectThemeColor = wdThemeColorAccent2 Code:
Debug.Print ActiveDocument.Styles(wdStyleHeading1).Font.Color If you're feeling brave, there is an article that explains theme colors in depth: Word Articles: Colours in 2007 |
#7
|
|||
|
|||
![]()
Thank you!!!
This is very helpful and will save me a lot of problems. Have a very nice day and thank you both for helping me out. |
![]() |
Tags |
color, style, theme |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Style Font Color Changes After Close?? | the.ronin | Word | 2 | 05-20-2018 07:26 PM |
Style Font Color: Background 1 | gmgj | Word | 3 | 12-20-2017 04:00 PM |
![]() |
Jennifer Murphy | Word | 14 | 03-19-2017 03:02 PM |
Font Color Question//.Replacement.Font.Color = 12611584 | rsrasc | Word VBA | 3 | 09-05-2015 09:03 PM |
Setting Font Color and Style "permanently" | wings1080 | Word | 5 | 12-19-2014 08:44 AM |