Mapping Flare styles to Word OUTPUT styles

This forum is for all Flare issues related to PDF, eBook, Microsoft Word, Adobe FrameMaker, XPS, and XHTML book targets.
Post Reply
kjgemmill
Propeller Head
Posts: 27
Joined: Mon Jun 06, 2011 8:43 am

Mapping Flare styles to Word OUTPUT styles

Post by kjgemmill »

***Note that this topic is about Word output FROM Flare not Word import TO Flare.***

Apologies to those who already know this answer but since I couldn't find it when I was looking I thought I would post my solution. Please let me know if you have a better answer! I'm a newbie!

My problem had to do with a need for Flare to output styles to Word and use the same styles I used when I imported the Word document. Especially the Headings. Someone told me they didn't think there was an option for that. But there "kinda, sorta" is.

I produce lots of documents that my contracting company must submit to the customer as Word docs. After I create a Word document from Flare we could not use the "Navigation Pane" option in Word because it didn't detect any "Headings" even though there are Flare headings. When I first tried to find the new heading styles in the Word Style pane I was unsuccessful. Then I realized that I could click the Options link in the Style pane and select to view "All Styles." Bingo. I found that my Flare headings are now Word styles named "h1," "h2," h3," etc.

Now all I had to do was modify each style to be based on the appropriate Word heading style and I was in business. So I modified "h1" to be based on "Heading 1" and so forth. Immediately all headings showed up in the Navigation pane. [By the way, my Word heading styles and Flare heading styles are virtually identical; even if they weren't I would just make them the same before I linked them. I'm trying to convert to Flare for content management, consistency and my own sanity. I don't expect my contracting company to change overnight but I'm working on them ;)]

I wish I didn't have to do this extra step but it is much better for me to do it before I send it out than to let customers see "No heading styles detected." And if the next owner of the doc changes the headings, text, etc. they can easily update all headings, the TOC, etc.

Another comment about the TOC proxy, it looked fine in Word and modifying my headings did not adversely affect it in any way. I updated it and everything still looked fine ;)
wclass
Propellus Maximus
Posts: 1238
Joined: Mon Feb 27, 2006 5:56 am
Location: Melbourne, Australia

Re: Mapping Flare styles to Word OUTPUT styles

Post by wclass »

Unfortunately Flare does not map its web styles to standard Word styles - I raised this as an issue years ago but it has never changed.

As you've discovered there are workarounds. One way is basing the H1 on the Heading 1 style, but another option is to just change the "outline level" of the H1, H2 styles to be a heading level rather than body text, and all your styles will show up immediately in the navigation pane.

Edit the Word paragraph style > In the General area of the Indents and Spacing tab there is a selection list for "Outline Level". If a style has a level of "Body text" it won't show up in the navigation pane - set it to one of Level 1 through 9, and it will be displayed.
Do this for all your required heading styles.

Or you can use this macro - I put this code into my Normal.dotm and created a button to it on my Quick Access bar.

Code: Select all

Sub assign_HLevels()

    On Error Resume Next

    ActiveDocument.Styles("h1").ParagraphFormat.OutlineLevel = wdOutlineLevel1
    ActiveDocument.Styles("h2").ParagraphFormat.OutlineLevel = wdOutlineLevel2
    ActiveDocument.Styles("h3").ParagraphFormat.OutlineLevel = wdOutlineLevel3
    ActiveDocument.Styles("h4").ParagraphFormat.OutlineLevel = wdOutlineLevel4
    ActiveDocument.Styles("h5").ParagraphFormat.OutlineLevel = wdOutlineLevel5
    ActiveDocument.Styles("h6").ParagraphFormat.OutlineLevel = wdOutlineLevel6
    
End Sub
I have raised a bug/enhancement to let us map Flare styles to Word ones, as that would suit me best, but it might be worth requesting that at least have an outline level set on the Flare styles.
Margaret Hassall - Melbourne
kjgemmill
Propeller Head
Posts: 27
Joined: Mon Jun 06, 2011 8:43 am

Re: Mapping Flare styles to Word OUTPUT styles

Post by kjgemmill »

Margaret - You are a genius! I used your code on a raw Word output file from Flare and it worked perfectly. Much easier than my method :lol:

On a similar topic I wonder if you might know how to change the shading of a heading now that it's in Word? This issue happens whether I use your method or my method to link the heading styles. (Word file output from Flare, of course; the issue doesn't exist in a native Word file.)

For example, I typically use white text for Heading 1, place a border around it and fill with blue. (Customer requests that.) But sometimes they change it to green. I have tried to modify the text and/or the h1 style but can't format it to have a different color background where the text is. The customer would have to modify the h1 style to select a different background but then also use the highlighter tool to change the color behind the text for every instance of the style throughout the document. I don't know why the area behind the text won't change to the new background color.

Of course this is simple if I do it in Flare but I guess the customer wants their docs in Word so they can make their own changes. I don't really know why :? :roll:

Thank you so much for all of your help with Word outputs. I've previously read many of your posts and appreciate your expertise in this area!

KJ
wclass
Propellus Maximus
Posts: 1238
Joined: Mon Feb 27, 2006 5:56 am
Location: Melbourne, Australia

Re: Mapping Flare styles to Word OUTPUT styles

Post by wclass »

I had to think about this one, as Flare seems to generate a non-(Word)standard background colour setting.

When you apply background shading to a Word paragraph, you can apply it to the paragraph or to just the text. When Flare generates the style, it looks like it applies shading to both, which is causing your problem when you try to change it to another colour.

As an experiment, in the generated Word document, select the heading, choose Borders and Shading, then select the Shading tab. On the right side of that tab is the "preview" section with an "Apply to" selection at the bottom where you can apply the shading to the text or to the paragraph. When you click the shading button on the ribbon it only applies to the paragraph. Basically you have to clear the background color from the text as well.
Select "Text" in the Apply To list and then choose No Color in the Fill section and click OK out of the dialog.

Of course, that would be a bit tedious to have to do each time, so here is a line that you can add to the other macro - this will clear the text background but retain the para colours:

Code: Select all

ActiveDocument.Styles("h1").Font.Shading.BackgroundPatternColor = wdColorAutomatic
This assumes that the heading style is still "h1" - you can change this as needed.

When you send the document to your client with your blue headings, they should be able to change to any colour they like if that's what they want.
Margaret Hassall - Melbourne
kjgemmill
Propeller Head
Posts: 27
Joined: Mon Jun 06, 2011 8:43 am

Re: Mapping Flare styles to Word OUTPUT styles

Post by kjgemmill »

Margaret,

Thank you again. It's magic! :D

KJ
Techno
Sr. Propeller Head
Posts: 193
Joined: Fri Dec 09, 2005 9:23 pm
Location: NORTHAMPTON, England, UK
Contact:

Re: Mapping Flare styles to Word OUTPUT styles

Post by Techno »

FWIW, can I add my request for an easy means to map Flare Style Names to Word Style Names please?

I appreciate there are workarounds, but when one pays so much for a "Single Source" program such as Flare I do feel that this is not an unreasonable request - or should I put it stronger - demand!

Just one example is where quite literally hundreds of teachers world-wide, need to apply Word Templates to produce Large Print for partially sighted students.

George.
George Bell
Techno-Vision Systems Ltd., U.K.
LTinker68
Master Propellus Maximus
Posts: 7247
Joined: Thu Feb 16, 2006 9:38 pm

Re: Mapping Flare styles to Word OUTPUT styles

Post by LTinker68 »

Techno wrote:FWIW, can I add my request for an easy means to map Flare Style Names to Word Style Names please?
Submit a feature request at http://www.madcapsoftware.com/bugs/submit.aspx.
Image

Lisa
Eagles may soar, but weasels aren't sucked into jet engines.
Warning! Loose nut behind the keyboard.
Techno
Sr. Propeller Head
Posts: 193
Joined: Fri Dec 09, 2005 9:23 pm
Location: NORTHAMPTON, England, UK
Contact:

Re: Mapping Flare styles to Word OUTPUT styles

Post by Techno »

Feature request submitted.

The macro has partially done what we need, however I was wondering if there is any way to have Flare use a specific custom Word Template instead of "Normal".

I need to find some easier way to change the Style names Flare creates to standard Word Style names, and am hoping this might be a way round the issue.

George.
George Bell
Techno-Vision Systems Ltd., U.K.
wclass
Propellus Maximus
Posts: 1238
Joined: Mon Feb 27, 2006 5:56 am
Location: Melbourne, Australia

Re: Mapping Flare styles to Word OUTPUT styles

Post by wclass »

Techno wrote:... however I was wondering if there is any way to have Flare use a specific custom Word Template instead of "Normal".
Flare can't do this at the moment, and the only workaround I've come up with involves complex macros.
I put in a feature request many versions ago, but there has been no major updates to the Word output for a few years now - extremely frustrating! The lack of style mapping is a major oversight.

My workaround steps:
- In Flare, generate a Word target - as simple as possible (make sure there is only one section)
- In Word, create a new document based on the template of your choosing
- Copy the Flare content into the new Word document
- Run the macros for mapping and fixing the styles (H1 to Heading 1 and so on).
Margaret Hassall - Melbourne
Techno
Sr. Propeller Head
Posts: 193
Joined: Fri Dec 09, 2005 9:23 pm
Location: NORTHAMPTON, England, UK
Contact:

Re: Mapping Flare styles to Word OUTPUT styles

Post by Techno »

Aside from running mnore than a basi cmacros, that's essentially what I've been doing. Of equal worry is the failure to carry over "Alt-Tags", for which I even have a Flare Big Report number for. I've around 600 screen shots in the main .chm file(s) and the prospect of adding all these again in Word, is daunting, to say the least. I'd even suggest this could be a Section 508 (accessibility) issue.

Just for background, my main project is authoring Help for a major, International braille production program, used by blind people as well as sighted. Hence Accessibility with screen reading software is a priority all round, inlcuding alternative format documentation, such as Word and eBooks.
George Bell
Techno-Vision Systems Ltd., U.K.
livetoski
Sr. Propeller Head
Posts: 135
Joined: Thu Aug 30, 2007 7:10 am
Location: Ottawa

Re: Mapping Flare styles to Word OUTPUT styles

Post by livetoski »

Wowee! Ask, or rather google and ye shall receive. Thanks so much for all this, and the feature request. I create word documents from Flare for Sales Engineers to present webinars and they can then provide their edits easily.
GeorgeBell
Sr. Propeller Head
Posts: 114
Joined: Thu Nov 22, 2012 3:27 am

Re: Mapping Flare styles to Word OUTPUT styles

Post by GeorgeBell »

I did finally realise what you also found, but what a pain!!

I perhaps should start another thread, but this sounds close enough - Alt Tags, intended to describe graphics.

It looks like the latest version does at least carry these over, BUT....... if you try to produce a Word file with embedded images, they disappear. Consequently you have to put up with the additional images folder created when you export to Word. In fairness, I've yet to determine if this is a Flare or Word issue.
livetoski
Sr. Propeller Head
Posts: 135
Joined: Thu Aug 30, 2007 7:10 am
Location: Ottawa

Re: Mapping Flare styles to Word OUTPUT styles

Post by livetoski »

Hi George,

Just a clarification:

now, when generating Word output, I go to target> Advanced > MS word output and select Embed images in output.

Are you saying that in Flare 9 this no longer works?

I have resisted upgrading to 9.0 as I am in the middle of a bunch of stuff and need time to suss out what the changes are. So far, my colleague has found a few things that keep me from upgrading. Flare is usually very responsive and fix things quickly, but there seems to be an issue with variables that got fixed and is now broken again.

Linda
wclass
Propellus Maximus
Posts: 1238
Joined: Mon Feb 27, 2006 5:56 am
Location: Melbourne, Australia

Re: Mapping Flare styles to Word OUTPUT styles

Post by wclass »

The embedding still works. What goes missing is any "ALT" text assigned to the image.

Unfortunately I don't have a solution, but it might be a problem with the way Word converts linked picture fields to embedded ones, so not a Flare issue. I'll have to test a bit more to work out the problem.
Margaret Hassall - Melbourne
WebHelpppp
Propeller Head
Posts: 78
Joined: Thu Jul 17, 2014 8:08 am

Re: Mapping Flare styles to Word OUTPUT styles

Post by WebHelpppp »

I copied the macro and tried to run it on the document and I received an error: Can't execute code in break mode. Any idea what is going on?
wclass
Propellus Maximus
Posts: 1238
Joined: Mon Feb 27, 2006 5:56 am
Location: Melbourne, Australia

Re: Mapping Flare styles to Word OUTPUT styles

Post by wclass »

WebHelpppp wrote:... error: Can't execute code in break mode.
This is a Word issue.
Word puts up that error when you try to run a macro when there is already one running in the background. Is there another macro that was paused? Did you set breakpoints on the macro and try to restart it? I'd jump into the VBA editor and stop all macros, then start again.
Margaret Hassall - Melbourne
Paulie
Sr. Propeller Head
Posts: 140
Joined: Sun Mar 01, 2015 3:01 pm

Re: Mapping Flare styles to Word OUTPUT styles

Post by Paulie »

Hi there,

Some additional tips:

If you place the above-mentioned code into a Macro called AutoOpen() the Macro will automatically run when the document is opened:

Code: Select all

Sub AutoOpen()
On Error Resume Next
    ActiveDocument.Styles("h1").ParagraphFormat.OutlineLevel = wdOutlineLevel1
    ActiveDocument.Styles("h2").ParagraphFormat.OutlineLevel = wdOutlineLevel2
    ActiveDocument.Styles("h3").ParagraphFormat.OutlineLevel = wdOutlineLevel3
    ActiveDocument.Styles("h4").ParagraphFormat.OutlineLevel = wdOutlineLevel4
    ActiveDocument.Styles("h5").ParagraphFormat.OutlineLevel = wdOutlineLevel5
    ActiveDocument.Styles("h6").ParagraphFormat.OutlineLevel = wdOutlineLevel6
End Sub
If you only want the macro to run if the document is generated from Flare, you can test for this using the document author property:

Code: Select all

Function TestIfFlareDocument()

If ActiveDocument.BuiltInDocumentProperties("Author") = "MadCap Software" Then
TestIfFlareDocument = True
Else
TestIfFlareDocument = False
End If

End Function
Finally, if you only want the Macro to run once per document, you can alter the company and author, so that the author property is no longer MadCap:

Code: Select all

Sub UpdateTitleAndAuthorInfo()
Set Doc = ActiveDocument
With Doc
.BuiltInDocumentProperties("Author") = "YourCompany"
.BuiltInDocumentProperties("Company") = "YourCompany"

End With

End Sub
All together, your code would look like this:

Code: Select all

Sub AutoOpen()

On Error GoTo ExitSub:

If Application.Documents.Count = 0 Then Exit Sub
If TestIfFlareDocument() = False Then Exit Sub

Application.ScreenUpdating = False
Call Assign_HLevels
Call UpdateTitleAndAuthorInfo
ActiveDocument.Save
ExitSub:
Application.ScreenUpdating = True
End Sub

Function TestIfFlareDocument()

If ActiveDocument.BuiltInDocumentProperties("Author") = "MadCap Software" Then
TestIfFlareDocument = True
Else
TestIfFlareDocument = False
End If

End Function

Sub Assign_HLevels()

    On Error Resume Next

    ActiveDocument.Styles("h1").ParagraphFormat.OutlineLevel = wdOutlineLevel1
    ActiveDocument.Styles("h2").ParagraphFormat.OutlineLevel = wdOutlineLevel2
    ActiveDocument.Styles("h3").ParagraphFormat.OutlineLevel = wdOutlineLevel3
    ActiveDocument.Styles("h4").ParagraphFormat.OutlineLevel = wdOutlineLevel4
    ActiveDocument.Styles("h5").ParagraphFormat.OutlineLevel = wdOutlineLevel5
    ActiveDocument.Styles("h6").ParagraphFormat.OutlineLevel = wdOutlineLevel6
    
End Sub

Sub UpdateTitleAndAuthorInfo()
Set Doc = ActiveDocument
With Doc
.BuiltInDocumentProperties("Author") = "YourCompany"
.BuiltInDocumentProperties("Company") = "YourCompany"
End With

End Sub
I hope this helps somebody out.
"In an ideal world, software should be simple, well designed, and completely intuitive to end users. In the real world, good documentation is king."
oceanclub
Sr. Propeller Head
Posts: 277
Joined: Thu Oct 10, 2013 4:45 am
Location: Dublin

Re: Mapping Flare styles to Word OUTPUT styles

Post by oceanclub »

Is it still the case that you can't map Flare styles to Word styles for output?

EDIT: I was looking at using a Word macro to convert the styles used by Flare (for example, H1, li, etc) to Word styles.

However, one problem is that Flare uses the style "li" for both numbered list elements _and_ unordered list elements. So I can't simply convert the style "li" to either "List Number" or "List Bullet". Does anyone know of a workaround?

P.
wclass
Propellus Maximus
Posts: 1238
Joined: Mon Feb 27, 2006 5:56 am
Location: Melbourne, Australia

Re: Mapping Flare styles to Word OUTPUT styles

Post by wclass »

<late reply>
Unfortunately, it IS still the case.
We have macros to convert the heading styles that work OK. However, the "li" and even some of the "p" styles are still a problem. For example, we might have paragraphs within List items in Flare that have the correct indentation, but if we convert P to Normal once it gets back to Word you can't be sure of globally replacing one with the other. The Ordered vs Unordered styles are particularly a problem.
And we still have issues with DIVs being converted to single cell tables.
I suppose I can put in ANOTHER bug-report/feature-request.
Margaret Hassall - Melbourne
Post Reply