Free Support Forum -

Mail Merge fails when the tablestart starts in one section and tableend in another section

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />We are getting the following exception

Exception-->java.lang.IllegalStateException: Mail merge region 'mLeter' is badly formed. TableStart and TableEnd should be in the same section, same table row or same table cell.

Please find attached 6883464.doc

Hi<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your request. TableStart and TableEnd are placed in different section. As workaround you can use Page Break instead Section Break. Please see the attached document.

Best regards.

We cannot remove the sections and insert page breaks manually as there are hundreds of templates already present.
Is there a way to programmatically find the section breaks and remove it using Aspose.Words library?(At this point of time we are not sure if the section break needs to be replaced with page break).
If you provide us java code snippet to remove section breaks it would be great.

Hi<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your request. You can try using the following code.

//Open document document

Document doc = new Document("6883464.doc");

DocumentBuilder builder = new DocumentBuilder(doc);

while (doc.getSections().get(1) != null)


//Move cursor to last paragraph of the first section


//Insert Page break


//Append content of the second section


// Remove second section



//Save output document"out.doc");

I hope this could help you.

Best regards.