Error when attempting document.Save(fileStream, SaveFormat.Docx)

Hello,

I’m attempting to run a simple merge into an existing document that contains merge fields in Shapes. The data source is a DataTable and appears to run when the table has a single row, but when the table contains multiple rows, an exception is thrown on the document.Save(fileStream, SaveFormat.Docx)( Object reference not set to an instance of an object.); step. Any help would be appreciated. I have provided some code below. Seems pretty straight forward.

string dataDir = @"C:\InstaMerge_Uploads\";

// Open an existing document.
Document document = new Document(dataDir + "MyMerge.docx");

DataTable myData = new DataTable("MyData");
DataColumn column = new DataColumn();

column = new DataColumn();
column.ColumnName = "donor_id";
myData.Columns.Add(column);


column = new DataColumn();
column.ColumnName = "prof_title";
myData.Columns.Add(column);

column = new DataColumn();
column.ColumnName = "address";
myData.Columns.Add(column);


DataRow row;
row = myData.NewRow();
row["donor_id"] = "34";
row["prof_title"] = "CEO";
row["address"] = "65 Ember Lane";
myData.Rows.Add(row);

row = myData.NewRow();
row["donor_id"] = "88";
row["prof_title"] = "CFO";
row["address"] = "132 Welsh Lane";
myData.Rows.Add(row);

document.MailMerge.Execute(myData);

MemoryStream fileStream = new MemoryStream();

document.Save(fileStream, SaveFormat.Docx);

@cholloway,

Thanks for your inquiry. Please ZIP and upload your input Word document (you are getting this problem with) here for testing. We will investigate the issue on our end and provide you more information.

Thanks @awais.hafeez,

I have attached my Word document.TestDocument.zip (70.1 KB)

@cholloway,

We tested the scenario and have managed to reproduce the same problem on our end. For the sake of correction, we have logged this problem in our issue tracking system as WORDSNET-16745. We will further look into the details of this problem and will keep you updated on the status of correction. We apologize for your inconvenience.

Great @awais.hafeez,

Thanks for your support.

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