Free Support Forum -

Aspose.Words for .NET. Insert formulas in document of Microsoft Word

Help me please. I have a specified set of formulas. I need to assign this formulas to fit merge fields inside document of Microsoft Word. <?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

For example, I have a formula - \sqrt{2}. And I want to merge this formula with document of Microsoft Word (doc). This document have merge field- “FirstFormula”.


new string[] {"FirstFormula"},

new object[] {"Formula1 "});

So, my question is, what value the field "Formula1 " must have to obtain \sqrt{2} in “FirstFormula” ?

Thanks in advance!


Thanks for your inquiry. If the formulas in your case are images, then you can use the same technique as described in the article below to insert these images into the document upon executing mail merge:

Hope this helps.

Best regards,

Hi. Thank you for your answer!

In my case formulas are not images, but simbolic representation of formulas.

I need to know, whether there is a combination of characters, which will be converted for exapmle into \sqrt{2} in document of Microsoft Word.

So I need to know, if OMML is supported in Aspose.Words. And if so, can you provide a code snippet?I need to use OMML when I merge some list of strings with document of Microsoft Word.

Thanks in advance!


Thank you for additional information. Unfortunately, at the moment, you cannot create OMML formulas in the document using Aspose.Words. At the moment, Aspose.Words simply preserves these objects upon processing the documents.

Currently, the simplest way to insert formulas into the document is including them as images. Another way is using EQ fields. Here is code example (if you need to insert this upon mail merge, you can use IFieldMergingCallback):

// Create empty document.

Document doc = new Document();

DocumentBuilder builder = new DocumentBuilder(doc);

// Insert some formula using EQ field.

// note: Aspsoe.Words does not update value of EQ fields, so you should update fieds in your document to the formula.

// You can learn more about switches used in EQ fields here:


string eqFieldCode = @"EQ x=h\s\do8(0)-\r(h\s\do8(0)-\f(2;h))";

builder.InsertField(eqFieldCode, null);

// Save output document


But this approach requires to build equation expressions, which requires more effort. You can learn more about EQ fields here:

Also, in this case, you will have to update fields in the document in MS Words to see your formulas.

Hope this helps.

Best regards.