I am currently working on a new version of DocX that will contain this functionality. I am not yet ready to upload this new version to codeplex as it requires more testing and I need to update the documentation.chm file with some new functions and examples.
However if you send me an email, I will send you back an early copy of this new version. Below is an example of how to use this new version to accomplish your task.
// Load a document.
using (DocX document = DocX.Load(@"Test.docx"))
// Find all instances of the string '<QuoteData>', I care not about the case.
List<int> indexList = document.FindAll("<QuoteData>", RegexOptions.IgnoreCase);
* Reverse this list.
* I do this so that when I insert new content (A table in this case)
* I do not affect the indexes of earlier instances of the string '<QuoteData>'.
// Loop through each found instance in reverse document order.
foreach (int index in indexList)
// Insert a Table at each found index.
Table t = document.InsertTable(index, 2, 2);
// Set the Table design (By default the table is invisible).
t.Design = TableDesign.ColorfulGrid;
// Remove all of the marker tags <QuoteData>, they are no longer useful.
document.ReplaceText("<QuoteData>", string.Empty, false);
* Save this document as Test2.docx.
* I don't want to override my origional document, incase I made a mistake.
} // Release the document from memory.
let me know if this helps.
kind regards and happy coding,