Append word document in template document when save

Hi team,
I use an C# object and a template file .docx to generate docx file dynamically with my object
example: (in my template file ) <<[ObjectStudent.NameStudent]>>
in my template file, i’d like append another docx file according to conditional like:
<<if [ObjectStudent.StudentId == 1]>> append doc1.docx <<elseif [ObjectStudent.StudentId == 2]>>append doc2.docx <> append doc3.docx <>
is it possible to do that? Thanks


Thanks for your inquiry. Yes, you can achieve your requirement using LINQ Reporting. Please read the following articles.
Working with Common Conditional Blocks
Inserting Documents Dynamically

Thanks for your reply.
it’s ok when i’d like append another simple docx without build
in my template file : <<doc ["\c:\remplace.doc"]>> it’s ok
but when i add -build : like <<doc ["\c:\remplace.doc"] -build>> it’s KO
i have this error message: Tag ‘doc’ is not well-formed. Character ‘-’ is unexpected
any solution please, i don’t understand for the bug


Thanks for your inquiry. To ensure a timely and accurate response, please attach the following resources here for testing:

  • Your input Word documents.
  • Please attach the expected output Word file that shows the desired behavior.
  • Please create a standalone console application ( source code without compilation errors ) that helps us to reproduce your problem on our end and attach it here for testing.

As soon as you get these pieces of information ready, we will start investigation into your issue and provide you more information. Thanks for your cooperation.

PS: To attach these resources, please zip and upload them.


attachment code with (5.4 MB)


Thanks for sharing the detail. Please replace student.age with student.Age in your exernalFile.docx file.

We have tested the scenario using the latest version of Aspose.Words for .NET 18.10 and have not found the shared issue. Please use Aspose.Words for .NET 18.10.

We have attached the input and output documents with this post for your kind reference. (37.2 KB)