Word-Dokumente zusammenführen (Office Interop & .NET), Formatierung beibehalten

Beim Zusammenführen mehrerer Word-Dokumente mit Microsoft Office Interop Assemblies (Office 2007) und ASP.NET 3.5 treten Probleme auf. Ich kann die Dokumente zusammenführen, aber einige meiner Formatierungen fehlen (nämlich die Schriftarten und Bilder).

Mein aktueller Zusammenführungscode wird unten angezeigt.

private void CombineDocuments() {
        object wdPageBreak = 7;
        object wdStory = 6;
        object oMissing = System.Reflection.Missing.Value;
        object oFalse = false;
        object oTrue = true;
        string fileDirectory = @"C:\documents\";

        Microsoft.Office.Interop.Word.Application WordApp = new Microsoft.Office.Interop.Word.Application();
        Microsoft.Office.Interop.Word.Document wDoc = WordApp.Documents.Add(ref oMissing, ref oMissing, ref oMissing, ref oMissing);

        string[] wordFiles = Directory.GetFiles(fileDirectory, "*.doc");
        for (int i = 0; i < wordFiles.Length; i++) {
            string file = wordFiles[i];
            wDoc.Application.Selection.Range.InsertFile(file, ref oMissing, ref oMissing, ref oMissing, ref oFalse);
            wDoc.Application.Selection.Range.InsertBreak(ref wdPageBreak);
            wDoc.Application.Selection.EndKey(ref wdStory, ref oMissing);
        }
        string combineDocName = Path.Combine(fileDirectory, "Merged Document.doc");
        if (File.Exists(combineDocName))
            File.Delete(combineDocName);
        object combineDocNameObj = combineDocName;
        wDoc.SaveAs(ref combineDocNameObj, ref m_WordDocumentType, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing);
    } 

Es ist mir egal, wie dies erreicht wird. Es könnte bei Bedarf auch als PDF ausgegeben werden. Ich möchte nur, dass die Formatierung übernommen wird.

Antworten auf die Frage(1)

Ihre Antwort auf die Frage