Hi Eric,
I am using Open XML PowerTools Version 4.2.
I do have a problem with the inserting an existing document into a document on a special location by using Id in the ‘Source’-constructor. They way I would like to do this is by inserting a content control with a specific unique Id and the replacing the content paragraph of the content control with: sdtContentPar.ReplaceWith(New XElement(PtOpenXml.Insert, New XAttribute(“Id”, “InsertFile”))) where stdContentPar is declared as XElement.
Sample code (taken from the sample DocumentBuilder01):
string source1 = “../../Flow.docx”;
string source2 = “../../~mvi52qa2vp.docx”;
List<Source> sources = null;
sources = new List<Source>()
{
new Source(new WmlDocument(source1), true),
new Source(new WmlDocument(source2), “InsertFile”)
};
DocumentBuilder.BuildDocument(sources, Path.Combine(tempDi.FullName, “Out3.docx”));
I get an ‘InvalidOperationException’ on the following line with ‘var p = s.SiblingsBeforeSelfReverseDocumentOrder().First();’ in the method ‘FixUpSectionProperties’.
The method s.SiblingsBeforeSelfReverseDocumentOrder() returns null, but I don’t understand why I get this returns null (which is causing the exception) and I hope you can give me some support.
I understand that you cannot research this by having the source documents (Flow.docx and ~mvi52qa2vp.docx”), but I currently I don’t see a way the post these documents.
I hope you can support me with this.
Kind regards,
Thierry