We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Inserting table with last rows merged in content control with MarkupLevel = Block corrupts the document

When I try to insert table in MS Word (a table coming from an Excel range) into a content control I get an error message that the content control cannot be inserted at the specified location. This only happens for tables where the last rows are merged. If merged rows are in the middle of the table everything works fine. Even more, if I create a table programmatically Word and add 2 rows merged & centered at the end of the table I can embed the table in a content control. This happens in Word outside of CDM.

Adding the content control programmatically with Aspose.Words does not throw an error when using MarkupLevel.Block but the content of the document gets corrupted and we cannot open the document anymore. Changing the markup level will throw the correct message from Aspose though, i.e. cannot insert.

Can you explain why the behavior is different for MarkupLevel.Block?

Internal ID: 143426

Message from MS Word:
capture.png (5.0 KB)

Sample.zip (21.9 KB)


Thanks for your inquiry. We have tested the scenario using the latest version of Aspose.Words for .NET 19.2 and have not found any issue with output document. The output document can be opened in MS Word 2016. So, please use Aspose.Words for .NET 19.2. We have attached the output document with this post for your kind reference.
19.2.zip (12.6 KB)

Thanks for your reply. Selecting the table in MS Word and trying to embed it into a rich text content control does not work so the behavior is certainly different in Word vs. Aspose.Words.
To prove this select the table in the Word document and go to the Developer tab, and click rich text content control. You’ll get the message from capture.png.

Looking at the sample code I uploaded, I cleaned up a bit more than I should have. The content control should contain only the table. With Aspose.Words when saving the document a paragraph is added and I do not want the extra paragraph in the StructuredDocumentTag.
In TryInsertObjectContentTag append the child to the tag only if it is not an empty paragraph, or simply:
if (!(childNode is Paragraph))


We have not found this issue while using MS Word 2016. Please check the attached image.

In your input document (excel_range.docx), there is one table and one empty paragraph. You are inserting them into content control. Please insert only table into content control.

Hi Tahir,

I don’t want the extra paragraph inside the content control and my previous answer mentioned how to change the code in order to remove it. Indeed the extra paragraph fixes the problem in this specific situation but it’s not what we want.
I retested everything with 19.2 and the problem is still there. I’m reattaching the modified code sample and the output documents.
Tests.zip (56.8 KB)

Thank you!


Thanks for sharing the detail. We have tested the scenario and have managed to reproduce the same issue at our side. For the sake of correction, we have logged this problem in our issue tracking system as WORDSNET-18147. You will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.

The issues you have found earlier (filed as WORDSNET-18147) have been fixed in this Aspose.Words for .NET 19.3 update and this Aspose.Words for Java 19.3 update.