none
Insert a new paragraph inside a merge field RRS feed

  • Question

  • Hi,

    I dont know if somebody asked this before (i've searched about it).

    I am trying to insert a new Paragraph inside a merge field using this code:

    mergefield.AppendChild(new Paragraph(new Run(new Text("New paragraph"))));

    And when I execute my program it works ok, but when I try to open the merged document there is an error related to document format.

    So, what am I doing wrong ? Is there any other approach for that ? 

    It only works when I do the following:

    mergefield.AppendChild(new Run(new Text("New paragraph")));
    Friday, July 11, 2014 2:14 AM

Answers

  • You might want to change your name to something a bit more condensed, so that it's possible for us to be polite and type a salutation... :-)

    I'm very much steeped in Word, so sometimes have trouble understanding how others expect/want it to behave. I have trouble understanding WHY you'd be trying to assign any value to a Merge Field. A Merge Field is designed to display the content of a data field, in a data source. You really cannot assign a "result" to it. At best, only a name, and there are limitations as to what may make up a name.

    Is your goal to REPLACE merge fields with other content?


    Cindy Meister, VSTO/Word MVP, my blog

    Friday, July 11, 2014 3:49 PM
    Moderator