How to output Microsoft Word heading styles

This forum is for all Flare issues related to PDF, eBook, Microsoft Word, Adobe FrameMaker, XPS, and XHTML book targets.
Post Reply
kcann
Propeller Head
Posts: 64
Joined: Wed May 27, 2009 7:03 am

How to output Microsoft Word heading styles

Post by kcann »

Hello!

I need to end up with Word output that uses Word's built-in heading styles (Heading 1, Heading 2, etc.) in order to use the Word navigation pane to display topics. Has anyone figured out how to do this?

Thanks!

KC
Nita Beck
Senior Propellus Maximus
Posts: 3672
Joined: Thu Feb 02, 2006 9:57 am
Location: Pittsford, NY

Re: How to output Microsoft Word heading styles

Post by Nita Beck »

To the best of my knowledge, Flare does not offer a means to map its heading styles to Word heading styles when generating Word output. The best solution I've found is to search-and-replace the Flare heading styles for Word heading styles in the generated Word document. Although I haven't done this myself, it's probably easy enough to create some Word macros in order to run the same search-and-replace swaps whenever needed.
Nita
Image
RETIRED, but still fond of all the Flare friends I've made. See you around now and then!
wclass
Propellus Maximus
Posts: 1238
Joined: Mon Feb 27, 2006 5:56 am
Location: Melbourne, Australia

Re: How to output Microsoft Word heading styles

Post by wclass »

Flare won't output to the standard Word styles - you can raise a bug like the rest of us:
https://www.madcapsoftware.com/feedback/bugs.aspx

I use the Find/Replace method once I have generated the Word doc (pretty quick to change H1 to Heading 1, H2 to Heading 2 and so on). I have a macro to do this - let me know if you'd like a copy and I'll send it when I'm back at my desk.
Margaret Hassall - Melbourne
mblackburn
Jr. Propeller Head
Posts: 3
Joined: Mon Jan 23, 2012 1:07 pm
Location: Research Triangle Park, North Carolina, USA

Re: How to output Microsoft Word heading styles

Post by mblackburn »

Hi Margaret -- If you have that macro available, would you send it to me also? Thanks!
wclass
Propellus Maximus
Posts: 1238
Joined: Mon Feb 27, 2006 5:56 am
Location: Melbourne, Australia

Re: How to output Microsoft Word heading styles

Post by wclass »

Here is the macro for converting Hx to "Heading x" styles.
It does not handle sub-classes (for example, styles like "h1.xyz")

Add this code to a Word template (normal.dotm would do)

Code: Select all

Sub ConvertHeadingsFindReplace()
' This routine searches for styles "Hx" and replaces with standard
' Word heading styles called "Heading x".
' It does this for all 6 levels of heading.
' It sets error checking off so that it skips any heading levels not
' found in the document.

    On Error Resume Next
    
'   Clear the formatting parameters

    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    With Selection.Find
        .Text = ""
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        .Format = True
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With

'   Run Find/Replace on heading levels.

    Selection.Find.Style = ActiveDocument.Styles("h1")
    Selection.Find.Replacement.Style = ActiveDocument.Styles("Heading 1")
    Selection.Find.Execute Replace:=wdReplaceAll
    
    Selection.Find.Style = ActiveDocument.Styles("h2")
    Selection.Find.Replacement.Style = ActiveDocument.Styles("Heading 2")
    Selection.Find.Execute Replace:=wdReplaceAll

    Selection.Find.Style = ActiveDocument.Styles("h3")
    Selection.Find.Replacement.Style = ActiveDocument.Styles("Heading 3")
    Selection.Find.Execute Replace:=wdReplaceAll
    
    Selection.Find.Style = ActiveDocument.Styles("h4")
    Selection.Find.Replacement.Style = ActiveDocument.Styles("Heading 4")
    Selection.Find.Execute Replace:=wdReplaceAll

    Selection.Find.Style = ActiveDocument.Styles("h5")
    Selection.Find.Replacement.Style = ActiveDocument.Styles("Heading 5")
    Selection.Find.Execute Replace:=wdReplaceAll
    
    Selection.Find.Style = ActiveDocument.Styles("h6")
    Selection.Find.Replacement.Style = ActiveDocument.Styles("Heading 6")
    Selection.Find.Execute Replace:=wdReplaceAll

End Sub
Margaret Hassall - Melbourne
Msquared
Propellus Maximus
Posts: 848
Joined: Mon Aug 06, 2012 10:19 am
Location: Southampton, UK

Re: How to output Microsoft Word heading styles

Post by Msquared »

Thanks very much for making this available Margaret.

Writing a macro to post-process Flare's output styles for Word to proper Word styles has been on my list of things to do for a long time. This will give me enough of a start to finish it myself.

One of the first feature requests I raised was for Flare to allow you to map to Word output styles, which is something that R***help does really well. :-( However, in 18 months of Flare use, I've managed without Word output so far, since the PDF output is so good. But sooner or later, a SME is going to ask for Word content to review, so I really should get on and sort it.
Marjorie

My goal in life is to be as good a person as my dogs already think I am.
Post Reply