4

I'm working on a book to be published in both paper and digital form. The prose part of the book can reflow on digital devices, but the book has a lot of displayed sections of programming code, and reflowing such displays (i.e., changing the line breaks) is highly undesirable. Some devices offer much longer lines than others, so one approach I'm considering is producing a manuscript where each code display is available in two forms: for wide displays and for narrow ones. To really make this work, I'd like to have conditional text in Word, because that will make it possible to produce two versions of the manuscript, one with wide lines in code displays and one with narrow ones.

I've done a lot of googling for conditional text support in Word, and the results are discouraging. SmartDocs from ThirtySix software seems like it would support what I want, but their product costs $695/year, which doesn't make a lot of financial sense for an independent author. Livelinx's Conditional Text appears to be an abandoned product, and the macros published in Gary Calwell's article don't handle braces in conditional text (which is a problem for me, because programming code displays contain lots of braces). A thread in an MS Community forum as well as one in in the Office Dev Center offer leads regarding DIY solutions, but my goal is to write a book, not to learn VBA.

Am I approaching this problem the wrong way? Is there an approach to conditional text (or, more generally, conditional content) in Word 2010 I should be considering? It just seems like it should not be that difficult to say "if (lines are wide) display this text, otherwise display this other text."

Thanks for any help and guidance you can offer.

4 Answers4

1

Adobe FrameMaker makes this sort of editing a breeze. I am creating a document right now in FM, which needs to have multiple print versions as well as markup for a wiki. I am able to include all these different requirements as conditional text, and then generate the necessary output, hiding and un-hiding the conditional text as needed. The wiki (TWiki) markup does require some additional "tweaking," but it is minimal, and I use NoteTab Pro for this job.

In addition, I also use Macro Toolworks Pro to assist with the markup, using macros instead of having to do repetitive tasks manually.

1

I've just got Gary Calwell's macros working in in Word for mac 2011. The problem was pasting from the 2-column PDF screwed up the line breaks, particularly IF statements (see http://www.daniweb.com/software-development/visual-basic-4-5-6/threads/47217/end-if-statements#)

To change the delimiters from curly brackets to some other obscure character(s), I think you would simply need to change the following lines in Function TagPara():

pos1 = InStr(myText, "{")
pos2 = InStr(myText, "}")

If myTag <> "" Then myRange.Text = "{" & myTag & "}"

I tried pasting in the complete code, without being screwed up by PDF columnation, but this forum doesn't seem to like such a long post; perhaps it can read the esteemed Mr Calwell's brilliant mind.

0

I came across these today researching similar to what you ask:

For simple short conditional text case, this has illustrated example I think: https://help.nintex.com/en-US/docgen/docservices/#docgen-sfdc/Services/templates/ConditionalTextWord.htm?Highlight=conditional.

For more complicated cases:

https://stackoverflow.com/questions/47335758/word-conditional-text

Can I hide a whole paragraph using Conditional Text Automation in Microsoft Word

and this one that is Windows only...

https://technicalcommunicator.wordpress.com/2011/01/31/how-to-modularize-using-microsoft-word-as-a-single-sourcing-tool/

and where the article referenced in that article including the needed binary to offer this support is since gone, but I found a cached copy in the web archive

https://web.archive.org/web/20151105041239/http://blogs.msdn.com/b/ericwhite/archive/2008/10/27/how-to-use-altchunk-for-document-assembly.aspx

David
  • 136
  • 8
0

I'd suggest my tool: LaxModules. Maybe it is an overkill for your needs, but you can ignore irrelevant functionality.

olpa
  • 172