Linebreak in ContentControl-Collection of common programming errors


  • msdn Hey,I do have a big problem concerning linebreaks within Plaintext- and Richtext-ContentControls.I want to put two ContentControls right behind each other. No space or linebreak in between. (“Field1″”Field2”)Then I want to add the following text to one of two controls:

    ActiveDocument.SelectContentControlsByTitle(“VI_Footer2”).Item(1).Range.Text = “Hello” & vbCrLf & “World”

    My Problem is, using Plaintext-ContentControls (Propertie for Linebreak is set to true), the Hello is within the ContentControl “VI_Footer2”, the String “World” is in the next line outside of the ContentControl!!! The ContentControls only behave correctly, if I put a linebreak between the two ContentControls. Then the “Hello linebreak World” is within the ContentControl…Using two Richtext-ContentControls placed right behind each other, it doesn’t work eather! I get the error message “Runtime error 5844 – One of the values passed to this method or property is incorrect.”Here too, if I put a linebreak between the two ContentControls, everthing works fine.I made an example to understand my problem. You can find it here ->

    http://www.laundsch.de/downs/LinebreakProblem.docm

    Has anyone experienced this problem too? Does anybody know a solution or workaround how to fix this problem!I would appreciate every advice!GreetzMax


  • msdn1 I found a solution to my problem:

    using “

    Chr(11)” instead of “vbCrLf” fixes my problem.
    Chr(11) is equal to “Shift + Return”.

    Using “

    Chr(11)” works with Plaintext as well as Richtext ContentControls.Maybe this answer helps out some other people too. I couldn’t find this anywhere in documentation.Greetz Max


  • msdn2 Yup that worked for me too.  Thanks for documenting your problem and your solution!

    Regards,

    Stephen Study