We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

using comments to split sections of a document


I have been trying to group sections of my document into "clumps", so I can re-order the document at runtime depending on user grouping (for mail merge).

I initially tried to use bookmarks, because of the bookmark navigator and the ability to select a bunch of the document as a bookmark, but this approach has been dropped as bookmark contents cannot contain section breaks.

Now I'm looking at using comments to select the regions of the document as the comments can include section breaks. Basically, I require regions in my document that match the names of my data tables in my data set pre mail merge. I can name the regions with the comments just fine, so I can find them, but I don't seem to be able to get the actually contents of the document that the comments surround so that I can build a new document in my order from the commented sections.

Is this not possible? Is there another way to achieve what I'm trying to do that is simpler?

Any help here would be greatly appreciated.



3 Replies

SK Sathish K Syncfusion Team June 16, 2014 12:22 PM UTC

Hi Paul,


Thank for your interest in Syncfusion products.


If your requirement is to copy the sections of the source document to the destination document, then it is not necessary to use the Bookmark navigator and comments. You can directly iterate the sections of the source document, clone the sections and add that in the destination document. Kindly use the below code to clone the sections.


Code snippet:

WordDocument source = new WordDocument("SourceFile.docx");

WordDocument destination = new WordDocument();


foreach (WSection section in document.Sections)





Please refer the below UG documentation link to know more about clone and merge.



You can also reorder the sections based on the index while adding the sections to the destination document.


Please let us know if you have any other questions.




PG Paul Griffiths-DUPLICATE ACCOUNT- USE DT# 147667 July 8, 2014 01:30 PM UTC

Thanks for getting back to me.
I probably didn't explain my problem very well. I did try this approach as one of my first, the problem for me being that sections do not define the end of a bookmark region. This could end midway through a section.
I have found an alternative solution now.

If I could ask a question about the mail merge data set syntax though that isn't covered in the documentation:

Command entry: ID=%Table2Name.ID% for Table1Name is fine and groovy, but what syntax would i use where the table names and column names have spaces. e.g.

My Column Name = %Table 2 Name.My Column Name%

or should i be using the t-sql syntax of:

[My Column Name] = %[Table 2 Name].[My Column Name]%

Hope you can help again.



SV Sarathkumar V Syncfusion Team July 9, 2014 10:38 AM UTC

Hi Paul,


Thank you for your update.

You could use the same syntax for the table and column names with spaces, you don’t need to use t-sql syntax at all.

My Column Name = %Table 2 Name.My Column Name%

For your reference we have prepared the sample with the Dataset contains DataTable with space in table and column names and which is used during the mail merge process. For your reference we have attached sample for the same.


Please let us know if you have any questions.



Attachment: mailMergeSample_82ec4108.zip

Live Chat Icon For mobile
Up arrow icon