2

I would like to revisit this question - Remove setting from style to inherit setting from base style - since the answer provided and voted doesn't really do what I want it to do.

A style in Word can inherit various properties from the style on which it was based. However changing any property of the new style breaks the inheritance, i.e. changes to the base style are not propagated to the child style. I would like a way, probably via a VBA macro, to re-establish the inheritance.

The method from the preferred answer from the previous question, linked above, succeeds in setting the font name to be the same as that for the base style, but does not re-establish the inheritance link. Further changes to the parent do not update the child.

How can I re-establish that inheritance link?

Many thanks

2
  • Have you checked to see if the "Update styles automatically" option would help you? word.mvps.org/faqs/macrosvba/UpdateStyles.htm
    – Adam
    May 12, 2015 at 23:39
  • 2
    Thanks Adam, but this is not really what I am looking for either. I do not really want to reset all of the standard styles. Also, styles based on those built-in styles would not update. I would like more fine grained control.
    – Jonathan
    May 14, 2015 at 7:07

2 Answers 2

1

I haven't tried it with every style setting, but at least for a few settings (font size and spacing after so far), simply changing the setting of the child style to match the parent will re-establish the inheritance.

7
  • That kind of defeats the purpose of having a new style ...
    – DavidPostill
    Jun 26, 2015 at 18:42
  • Jonathan: I cannot reproduce your problem.  I can confirm that Mark's answer works for me, in Word 2013.  Also, in this forum post (How to inherit a font from another style?), dated 2004, Margaret Aldis (Microsoft Word MVP) confirms that it works that way. Jun 27, 2015 at 17:50
  • @DavidPostill: I don't understand your comment. Jun 27, 2015 at 17:51
  • @Scott Changing the child style to match parent to re-establish inheritance means the child style is now the same as the parent. This defeats the purpose of a having child style in the first place (which is to be different from the parent).
    – DavidPostill
    Jun 27, 2015 at 17:54
  • 2
    @DavidPostill: But style inheritance is not all-or-nothing.  It's not based on the entire style; it's granular to the attribute/property level.  So, changing the space-after-paragraph setting on Style2 to be equal to the space-after-paragraph setting on Style1 reestablishes Style2's inheritance of the space-after-paragraph setting (and nothing else) from Style1, while allowing Style2 to be different from Style1 in dozens of other ways. Jun 27, 2015 at 18:10
0

TL;DR: Edit the XML definition of the style.

Setting the value to the BaseStyle value is a one-time fix, not something that restores inheritance. The values are explicitly set to the values of the base style, BUT not to inherit.

Example: Char style C1 is based on the defaults of para style List Number 2. LN2 is based on Normal. Normal font is Calibri 11 pt black. Open C1 and you see its font & size are blank. Change to Arial 10 and it's now forever an explicit value. Run the macro and C1 is set back to Calibri 11 pt black - not blank (inherited)! Change LN2 and C1 stays Calibri 11 pt black - not LN2's font and size. I haz a sad.

From an XML perspective, style grrr has w:color set to green. Its base style has 11 pt text

<w:style w:type="character" w:customStyle="1" w:styleId="grrr">
    <w:name w:val="grrr"/>
    <w:basedOn w:val="DefaultParagraphFont"/>
    <w:uiPriority w:val="1"/>
    <w:qFormat/>
    <w:rsid w:val="009014C2"/>
    <w:rPr>
        <w:color w:val="00B050"/>
    </w:rPr>
</w:style>

Note w:sz is not defined.

After a manual change to 8 pts the XML appears as such: <w:sz w:val="16"/>

After use of the .BaseStyle macro above, it is explicitly set to 11 pts in the XML: <w:sz w:val="22"/>

That's not inheritance. That's explicit setting to the value of the base style.

Manual removal of <w:sz w:val="22"/> from the XML restored inheritance. And that is a ridiculous solution.

In the UI, we see the font size is 11 pts. That's the same value as the base style, and was set using the BaseStyle approach, but it's the same as manually setting it to 11. enter image description here

When I change the base style, text formatted using Asset Title doesn't change. There's no inheritance - it's just 11 pts.

After editing docname.docx\word\styles.xml (without linearizing!) to remove <w:sz w:val="22"/> we see inheritance has been restored - the font size control is empty, which is Word's way of telling us the value is inherited.

enter image description here

When I change the base style, text formatted using Asset Title changes. There's inheritance - it's 11 pts because its parent is 11 pts.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .