none
Generate multiple docs by substituting values for placeholders RRS feed

  • Question

  •  Hi,

    Does anyone have a utility that would generate multiple documents using one template with placeholders.

    The placeholders' values can be in the form of text or number.

    I could have written a script in unix, but restricted to only windows platform.

    Kindly let me know if anybody has it handy or any work around for me to do, as i need to generate 500 + docs.

    Thanks.

    Regards

    Sony

    Tuesday, May 20, 2014 5:22 PM

Answers

  • Hi,

    Based on my understanding, you wanted to fill specified text into Content control’s placeholders.

    I noticed you didn’t mention to what’s technology were you using in this project, but you post this case in Open XML forum.

    I just wrote a sample to modify the placeholder text for the content control using openXml sdk.

    using DocumentFormat.OpenXml.Wordprocessing;  

    using (WordprocessingDocument doc = WordprocessingDocument.Open("D:\\Test.docx", true )) { // You can specified which content control did you want to modify. SdtBlock RichTextSdt = doc.MainDocumentPart.Document.Body.Descendants<SdtBlock>().ElementAt(0); RichTextSdt.Descendants<Text>().First().Text = "Test"; doc.MainDocumentPart.Document.Save(); }

    Before:

    After:

    Regards,

    Marvin


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Wednesday, May 21, 2014 6:27 AM
    Moderator