Free Support Forum - aspose.com

Loss of font selection when merging

When the attached documents are merged together using the code below, the last document reverts to Times New Roman for it's font selection. How can we avoid having the font revert to Times New Roman? We are using Aspose.Word 3.3.5.

Individual Documents
3311_CoverPage.doc
3311_TabPage_878.doc
3311_TOCPage.doc
687c2c55-597f-41d6-bc41-673cbd188838_HF.doc

The above are merged together in that order to produce 3311_Final.doc but the last section entitled "Housing" should not be Times New Roman.

Code

Private Sub Append_Word_Doc(ByRef DestDoc As Aspose.Word.Document, ByVal SrcDocPath As String)

Dim SrcDoc As Aspose.Word.Document
Dim DocSection As Aspose.Word.Section
Dim TempSection As Aspose.Word.Section
Dim x As Integer

'----- Set License
Dim license As License = New License
license.SetLicense("Aspose.Word.lic")

'----- Get the source Word doc
If Not File.Exists(SrcDocPath) Then Exit Sub
SrcDoc = New Aspose.Word.Document(SrcDocPath)
'----- Copy the section from SrcDoc to DestDoc
For x = 1 To SrcDoc.Sections.Count
DocSection = SrcDoc.Sections(x - 1)
TempSection = CType(DestDoc.ImportNode(DocSection, True), Aspose.Word.Section)
DestDoc.Sections.Add(TempSection)
Next

SrcDoc = Nothing

End Sub

Thanks,

Justin

You should use the Document.ImportNode(Node, Boolean, ImportFormatMode) overload and set ImportFormatMode to KeepSourceFormatting.

Works perfectly now. Thanks so much for a quick reply.