Style Woes on Export to DOCX

This forum is for all Flare issues related to PDF, eBook, Microsoft Word, Adobe FrameMaker, XPS, and XHTML book targets.

Style Woes on Export to DOCX

Postby thforbes on Thu Feb 25, 2021 10:28 am

Part of my organization's workflow involves exporting manuals to DOCX so that they can be approved. We've been working on streamlining this process, and we've found some successes there, but one thing continues to be a problem: when Flare exports docx files, the styles in use in the resulting document are a bit... exotic. By which I specifically mean, the system will create multiple versions of various styles, appending these with a "_1" or "_2." We have an existing, mostly-useful workaround involving MS Word macros that goes through and fixes these things, but unfortunately, it can only fix what it knows what to fix. Which is to say, if Flare spits out a style that's not a hard-coded part of the macro, it won't get fixed. And boy, Flare really loves to spit out new styles on different documents. For example, the H2s in one document are all tagged with class="heading2". The resulting Flare output gave us "h2_heading2," "h2_Heading2," "h2_heading2_1," and "h2_Heading2_1". I'd rather not keep expanding the macro to catch all of Flare's distinct outputs, so is there any method that anyone has found to prevent Flare from freestyling quite as hard?
thforbes
Jr. Propeller Head
 
Posts: 3
Joined: Wed May 24, 2017 12:23 pm

Re: Style Woes on Export to DOCX

Postby ChoccieMuffin on Tue Mar 02, 2021 10:15 am

I can't offer any suggestions, but I sympathise with your pain. Word just refuses to play nicely with Flare, and it's a massive PITA! Best of luck, and sorry I can't help.
Started as a newbie with Flare 6.1, now using Flare 2019r1 and 2020.
Report bugs at http://www.madcapsoftware.com/bugs/submit.aspx.
Request features at https://www.madcapsoftware.com/feedback ... quest.aspx
ChoccieMuffin
Senior Propellus Maximus
 
Posts: 2462
Joined: Wed Apr 14, 2010 8:01 am
Location: Surrey, UK

Re: Style Woes on Export to DOCX

Postby wclass on Tue Mar 23, 2021 3:57 pm

We used a macro that converted anything with the specified prefix to a standard Word style, so we didn't have to keep adding in all the possible ones that Flare came up with.
For example, all of your examples - "h2_heading2," "h2_Heading2," "h2_heading2_1," and "h2_Heading2_1" - since they all start with "h2_" would be converted to Word style "Heading 2".
We had a similar macro for converting "p_nnn" to Normal.
I will post the code.
Margaret Hassall - Melbourne
wclass
Propellus Maximus
 
Posts: 1237
Joined: Mon Feb 27, 2006 5:56 am
Location: Melbourne, Australia

Re: Style Woes on Export to DOCX

Postby wclass on Tue Mar 23, 2021 4:00 pm

Macro to convert Flare generated web/html headings to Word

Code: Select all
Sub stl_convert_all_StandardHeadings()
' ----
' This routine converts web-type headings (H1) to standard Word ones (Heading 1),
' in the current active document.
' It loops through the document checking the style of each paragraph found,
' updating as it goes.
' Default is to convert all 6 levels of headings (H1 - H6).
' abd then convert subclasses (h1_something)

Dim rngSave As Range
Dim tPara As Paragraph
Dim tStyle As String
Dim newStyle As String
Dim stylePrefix As String

    ' save current location
    Set rngSave = Selection.Range
   
    For Each tPara In ActiveDocument.Paragraphs
        tStyle = tPara.Style
        If Len(tStyle) <= 2 Then
            stylePrefix = tStyle
        Else
            stylePrefix = Left(tStyle, 3)
        End If
        Select Case LCase(stylePrefix)
            Case "h1", "h1_"
                newStyle = "Heading 1"
            Case "h2", "h2_"
                newStyle = "Heading 2"
            Case "h3", "h3_"
                newStyle = "Heading 3"
            Case "h4", "h4_"
                newStyle = "Heading 4"
            Case "h5", "h5_"
                newStyle = "Heading 5"
            Case "h6", "h6_"
                newStyle = "Heading 6"
            Case Else
                newStyle = ""
        End Select
        If newStyle <> "" Then
            tPara.Style = newStyle
        End If
   
    Next tPara
   
   
    ' return cursor to  original location
    rngSave.Select
    Selection.Collapse
   
End Sub
Margaret Hassall - Melbourne
wclass
Propellus Maximus
 
Posts: 1237
Joined: Mon Feb 27, 2006 5:56 am
Location: Melbourne, Australia

Re: Style Woes on Export to DOCX

Postby wclass on Tue Mar 23, 2021 4:03 pm

Macro to convert web/html paragraphs to Word styles.

Code: Select all
Sub stl_convert_all_paras_normal()
' ----
' This routine converts web-type paragraphs (p, p_1, p_2, etc) to Word Normal
' in the current selection in the active document.
' It loops through the document checking the style of each paragraph found,
' updating as it goes.

Dim rngSave As Range
Dim tPara As Paragraph
Dim tStyle As String
Dim newStyle As String
Dim stylePrefix As String

    ' save current location
    Set rngSave = Selection.Range
   
    For Each tPara In ActiveDocument.Paragraphs
        tStyle = tPara.Style
        If Len(tStyle) <= 2 Then
            stylePrefix = tStyle
        Else
            stylePrefix = Left(tStyle, 2)
        End If
        Select Case LCase(stylePrefix)
            Case "p", "p_"
                newStyle = "Normal"
            Case Else
                newStyle = ""
        End Select
        If newStyle <> "" Then
            tPara.Style = newStyle
        End If
   
    Next tPara
   
    ' return cursor to  original location
    rngSave.Select
    Selection.Collapse
   
End Sub
Margaret Hassall - Melbourne
wclass
Propellus Maximus
 
Posts: 1237
Joined: Mon Feb 27, 2006 5:56 am
Location: Melbourne, Australia


Return to Printed Documentation Targets

Who is online

Users browsing this forum: No registered users and 6 guests

cron