Results 1 to 8 of 8
  1. #1
    New Lounger
    Join Date
    Oct 2001
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Custom Heading Styles (97) (97)

    I am required to use a client's template to produce some specifications and other reports. In their wisdom the template authors have decided not to use Word's built-in heading styles but have created their own. These styles are called "DW$_Heading 1, DW$_Heading 2 &c. and are not linked nor are they tied to a specific List Gallery.

    I attempted to link these styles using VBA (via the techniques discussed on the mvps.org website) and ran into problems. The styles did not exhibit the same behaviour as the Word built-in heading styles, most significantly they didn't promote/demote levels as I would expect. For example, when a heading was changed from say a level 2 to level 4 the style didn't change from "DW$_Heading 2" to "DW$_Heading 4" as I would expect to happen with properly linked Word built-in heading styles.

    My questions are:
    1. Is the behaviour I expect to see a special property of the word built-in styles?
    2. If 1, can I force this behaviour programatically for non built-in styles somehow? or
    3. If not 1, is there something missing from my code (attached) that would give me the behaviour I expect?

    The code used is an adaptation of the macro I use to set the built-in styles which seems to work well.

    regards
    Grant Cartledge
    Melbourne, Australia
    Attached Files Attached Files

  2. #2
    Super Moderator
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    3,852
    Thanks
    4
    Thanked 259 Times in 239 Posts

    Re: Custom Heading Styles (97) (97)

    Grant

    Now isn't that interesting... I was about to say that promote and demote works for all outline lists but you also assigned outline levels for use in the Outline View as well. There does appear to be a power struggle going on here. If you set all the DW Heads to .OutlineLevel = wdOutlineLevelBodyText then they can be promoted and demoted with the behaviour you expect but they disappear when showing levels in outline view and they don't appear in a TOC built on outline levels.

    You may be able to force this behaviour programmatically but it may be easier to just build a template with style aliases to merge both variants of the style. If your template has a style called "Heading 1, DW$_Heading 1" then you really have one style which works consistently and you get around the clients template silliness.
    Andrew Lockton, Chrysalis Design, Melbourne Australia

  3. #3
    3 Star Lounger
    Join Date
    Apr 2004
    Location
    Boston, Massachusetts, USA
    Posts
    389
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Custom Heading Styles (97) (97)

    I agree with Andrew that it would probably be easier to just merge the client's stuff with your own template, using the built in styles based on the client's, using aliases.

    Obviously you don't want to return the files to them that way, but here's a way around that. Say you've put the client's document into your own template, which has, as Andrew suggested, styles like "Heading 1, DW$_Heading 1". Now, if you try to rename that style to strip out the "Heading 1", Word (or VBA) won't complain, but they won't let you do it, either.

    But ... if you save the file as RTF, and open it up in a text editor, you can pretty easily locate the style table and the definition for "Heading 1, DW$_Heading 1". Delete the "Heading 1," part. When you re-open the file in Word, Word will re-generate an actual Heading 1 style, but leave yours intact, with all the formatting.

    I don't know the complexity of your documents, and I certainly can't promise this will work without any problems, but if the strategy works for you, it's the kind of thing that could be implemented pretty easily in Perl (from start to finish -- opening the Word files, saving them as RTF, making the substitution, and opening them back up in Word). Then again, this client may not be worth the trouble.

  4. #4
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Custom Heading Styles (97) (97)

    Just as a footnote, the poster specified Word 97, which I don't believe combined style names in that manner. I'm not sure whether this makes the solution easier or more difficult.

  5. #5
    3 Star Lounger
    Join Date
    Apr 2004
    Location
    Boston, Massachusetts, USA
    Posts
    389
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Custom Heading Styles (97) (97)

    I don't have access to Word 97 right now to check for sure (it's at home), but I'm almost certain it supported style aliases.

    Here's a link to info on the binary file format for Word 97, and it specifically mentions style aliases.

    http://www-aix.gsi.de/~bio/DOCS/wword8.html

    But I could certainly be mistaken.

  6. #6
    5 Star Lounger kmurdock's Avatar
    Join Date
    Feb 2003
    Location
    Pacific Grove, California, USA
    Posts
    716
    Thanks
    10
    Thanked 34 Times in 28 Posts

    Re: Custom Heading Styles (97) (97)

    I'm using Word XP and discovered the following:

    As previously noted, promote and demote didn't work on my custom headings. I was careful to make sure my headings were all associated with an outline level on the Styles | Paragraph dialog.

    In Word XP, in the Styles pane, if you click Modify on one of the built-in Heading styles, two context-sensitive options are promote and demote. This is not true on my custom styles KHeading 1, KHeading 2, etc. Even if I base them on Heading 1, Heading 2, etc. So there is clearly something hard coded about the built-in styles that is not apparently available to a custom style.

    I was able to use increase indent and decrease indent to promote and demote in the document.

    My custom headings did appear in the outline view in Word XP, probably because they were clearly associated with an outline level.

    My custom headings also did appear in a Table of Contents automatically, again probably because they were clearly associated with an outline level.

    What does all this tell you? I no longer have Word 97, so I don't know if you'll have the same results, but make certain each Heading is associated with a level in the paragraph dialog (not just in the numbering dialog). It's something to try... <img src=/S/shrug.gif border=0 alt=shrug width=39 height=15>

    Kim

  7. #7
    Super Moderator
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    3,852
    Thanks
    4
    Thanked 259 Times in 239 Posts

    Re: Custom Heading Styles (97) (97)

    Jefferson

    Word has had style aliases for a long time and they were certainly in Word 97. I don't know the value of Andrew's char char macro running in earlier versions of Word but I will vouch for his use of aliases in Word 97.
    Andrew Lockton, Chrysalis Design, Melbourne Australia

  8. #8
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Custom Heading Styles (97) (97)

    My mistake, sorry all for the misdirection.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •