Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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.

share|improve this question
    
Which devices and what viewers will be used to view the document? Will the format you save the document as still be a Microsoft Word document? –  Adam Mar 14 '13 at 1:00
    
@Adam: The distribution format for digital devices will be epub, and the viewers/devices on which it is to be viewed includes Kindles and iPads (all versions), plus any other devices in the future that can handle epub (or whatever other format becomes sufficiently popular). The master ms will remain in Word, and changes to that document will have to be propagated through to epub (and, for print, PDF) for future printings, assuming there is sufficient demand. –  KnowItAllWannabe Mar 14 '13 at 2:48
    
well in that case you should make sure any solution you consider will work with the exporter you are using to save the word document to EPUB. It might well be all of those techniques you described in your opening post won't be picked up by the exporter so the effort would be futile. –  Adam Mar 15 '13 at 9:44
    
As a simple solution, have you tried substituting the spaces in your lines of code with non-breaking spaces so they (hopefully) appear better in EPUB? –  Adam Mar 15 '13 at 9:45

2 Answers 2

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.

share|improve this answer

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

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.