-1

我正在尝试将 6 个 word 文档合并为单个文档,我能够合并所有六个文档,但我遇到了格式以及页眉和页脚的问题。

Word.Application objWordApp = new Word.Application();
Word.Document objWordDoc = new Word.Document();
object missing = Type.Missing;
object visible = true;
object objCreateDoc = "E:\\MergeTemplates\\Temp.doc";
string strNewDocPath1 = "E:\\MergeTemplates\\Templates\\Template1.doc";
string strNewDocPath2 = "E:\\MergeTemplates\\Templates\\Templates2.doc";
string strNewDocPath3 = "E:\\MergeTemplates\\Templates\\Template3.doc";
object objPageBreak = Word.WdBreakType.wdPageBreak;

try
{

    objWordDoc = objWordApp.Documents.Open(objCreateDoc, false, false, ref missing,
                                        ref missing, ref missing, ref missing, ref missing,
                                        ref missing, ref missing, ref missing, true,
                                        ref missing, ref missing, ref missing, ref missing);

    objWordDoc.Activate();
    objWordApp.Selection.InsertFile(strNewDocPath1, ref missing, true, ref missing, ref missing);
    objWordApp.Selection.InsertBreak(ref objPageBreak);
    objWordApp.Selection.InsertFile(strNewDocPath2, ref missing, ref missing, ref missing, ref missing);
    objWordApp.Selection.InsertBreak(ref objPageBreak);
    objWordApp.Selection.InsertFile(strNewDocPath3, ref missing, ref missing, ref missing, ref missing);
    objWordApp.Selection.InsertBreak(ref objPageBreak);
    objWordApp.ActiveDocument.SaveAs(objCreateDoc, ref missing, ref missing,
                                    ref missing, ref missing, ref missing, ref missing,
                                    ref missing,ref missing, ref missing, ref missing);
    objWordApp.ActiveDocument.Close(ref missing, ref missing, ref missing);
}

我正在尝试使用 InsertFile() 将多个 word 文档合并为单个 word 文档。

我可以合并它,但字体和页眉和页脚不匹配。我想要与多个文档中相同的格式。有没有办法使样式匹配?

4

1 回答 1

0

尝试全选并从每个文档中复制并粘贴到新文档中

于 2013-11-16T15:38:00.710 回答