I have a Word template that I need to insert HTML from a database and also merge existing Word documents into this template. They need to go in a certain order as well. My problem is that I insert some HTML, merge a Word file and then insert some more HTML but things get out of order. The resulting Word document has the HTML from the first insert followed by the HTML from the third step and then the merged Word document is at the end of the file. Any suggestions would be much appreciated.
When I insert HTML, I use this code:
And I use this function to merge a Word document:
Public Shared Sub MergeDocs(ByVal sourceDoc As Aspose.Words.Document, ByRef destDoc As Aspose.Words.Document)
For Each sect As Aspose.Words.Section In sourceDoc.Sections
If sect.Equals(sourceDoc.FirstSection) Then
sect.PageSetup.SectionStart = SectionStart.Continuous
Dim newSection As Aspose.Words.Section = destDoc.ImportNode(sect, True, ImportFormatMode.KeepSourceFormatting)
Hi<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />
Thanks for your inquiry. I think you can use builder.MoveToDocumentEnd() after appending a document and before inserting the second portion of HTML.
Hope this helps.
That worked. Thanks.