![]() |
|
|
|
#1
|
|||
|
|||
|
Although you may think linked styles to be cumbersome, this is precisely the use case that they were designed for.
As their name suggests, linked styles consist of two separate styles - a paragraph style and a character style with the same name plus the suffix " Char". When a linked style is applied via the UI Word decides which style to apply dependent on context. When applied via VBA it is up to you to decide which style to apply. To apply a heading style to the entire paragraph you can either use the name: Code:
Selection.Range.Style = "Heading 2" Code:
Selection.Range.Style = wdStyleHeading2 Code:
Selection.Range.Style = "Heading 2 Char" Code:
Selection.Range.Style = ActiveDocument.Styles(wdStyleHeading2).NameLocal & " Char" |
|
#2
|
|||
|
|||
|
Bingo, that's it, thanks! Interesting how Word decides to apply char or para style based on user behavior. Makes sense.
And to be clear, I don't find the linked styles cumbersome, I find manually applying two styles to each paragraph to be cumbersome. My code now eliminates at least one step of that. |
|
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
Word 2007: Unable to change character style, when using a linked Char/Para style format
|
Last Chance | Word | 3 | 06-09-2021 12:52 PM |
| Why does paragraph inherit style of the following paragraph? | WADEVCAMP | Word VBA | 2 | 04-08-2019 02:13 PM |
How to globally change the formatting of a bullet style to another style?
|
ravl13 | Word | 5 | 03-10-2013 05:04 PM |
| Don't indent the fist line of the first paragraph after a style change | Inspirement | Word | 1 | 04-08-2012 05:30 AM |
| Character style stripped while applying paragraph style | sams_gates | Word | 0 | 08-29-2009 02:03 AM |