xmlnode misbehavior in Word

I'm working on a word 2003 document using xmlnodes to allow the action panes to change while navigating the document.

Three of the nodes will may contain optional muilti-line text, so I have the nodes all on the same line (so that the third node won't have 2 extra blank lines above it when it is populated but the first 2 aren't).

<attachments><cc><distribution>

A string variable is set from a series of combo boxes and/or text boxes, including needed vbCRLF's, and the xmlnodes text value is set to the value of the string variable.

This works fine if the xmlnodes are on separate lines, but place all the text following the first vbCRLF outside of the nodes when on the same line.

Does anybody have a workaround

Richard



Answer this question

xmlnode misbehavior in Word

  • DaFlookie

    Promised Followup:

    After a little playing around, I determined that I could accomplish my goal by using chr(11) in my code rather than vbcrlf. Much easier and straightforward. However, I still appreciate your input, which I may still need in another context.

    Richard Stawicki


  • TopCat61

    This behavior is by design in Word. When you place the nodes on the same line, that means you are making tunring them into inline-level elements, not paragraph level elements. So if you attempt to insert crlfs inside them (which become new paragraphs) Word refuses to put that into the inline level elements, since that'd break the wellformedness of the document. So it puts the stuff after the first paragraph mark after the inline element.

    It works ok when the elements are on separate lines, because that means they are paragraph level elements and can accept multi-paragraph content.

    one workaround I can think of is to play with Hidden formatting (Range.Hidden property) around the paragraph marks or the tags themselves - see what works - and then programmatically remove the hidden formatting as needed.

    See if this helps.


  • elmtree95

    That's what I was afraid of. I'll come back and document if your suggestion works for me.
  • xmlnode misbehavior in Word