We have a problem with a WinWord file. In the header section we have an INCLUDETEXT refering to au bookmark in another Doc file.
We tried many options but we can’t import the bookmark content with the data merged.
For instance,
A MainDocument.doc contains this in the header section:
{INCLUDETEXT “d:\AsposeRepro\{QUOTE entete{MERGEFIELD A001}{MERGEFIELD A004 #00}.doc}” E}
this should insert the bookmark “E” existing in the document d:\AsposeRepro\enteteE11.doc.
A datafile contaning these datas:
A001|A002|A003|A004
E|Cabinet|PARIS|11
Another file d:\AsposeRepro\enteteE11.doc containing references to MERGEFIELDs {MEGERFIELD A002}
To ensure a timely and accurate response, please attach the following resources here for testing:
Your input Word document.
Please attach the output Word file that shows the undesired behavior.
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.
Here are the files you expected as an example:
maquette.doc is the main document to merge
data.don is the data file
enteteE11.doc is the document to insert inside maquette.doc
resultat.docx is the merged document using ASPOSE
sample.doc is the document merged manually.
program.cs is the source code in c#. AsposeRepro.zip (324.0 KB)
In your code, the IncludeText method does not insert the sub document into header and footer. Please insert the sub document at the place of IncludeText field using DocumentBuilder.InsertDocument method after performing the mail merge for sub document.
is it possible to insert only a part of a document identified by a bookmark?
I’m able to import the whole subDoc containing the merged values but I cannot import the content of a bookmark (ie: enteteE11.doc contains 2 bookmark E and P)
It seems to work but I don’t have the content of paragraphs in the header, but only empty lines.
Here is the changes I made on my program.cs.
(at line 224, I tried to save each bookmark content in a separate file and theses files have no text merged whereas the temporary file save in line 214 has got all the text merged.Program.zip (3.1 KB)
In DebugMode, in the while loop I can see each Node of type Paragraph containing the text I want to insert.
But at the end, I only have empty pagraphs.
It is nice to hear from you that your problem has been solved. Please feel free to ask if you have any question about Aspose.Words, we will be happy to help you.