VSTO add multiple XML Content into content control

33 Views Asked by At

hey i searched everything but found nothing on this case. I want to insert multiple XML-contents into a chosen Word content control. My foreach loop overwrites the old XML with each pass. So it effectively only inserts the last XML content from my collection. Is there a way to append XML content in a range instead of replacing it?

            foreach (ContentControl cc in targetDoc.ContentControls)
            {
                if (cc.Tag == "X_Placeholder")
                {
                    foreach (var tbContent in textBrickContentList)
                    {
                        cc.Range.InsertXML(tbContent);
                    }
                }
            }
1

There are 1 best solutions below

0
manti13 On

found the solution, its:

targetDoc.Range(cc.Range.End, cc.Range.End).InsertXML(tbContent);