我正在尝试将 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 文档。
我可以合并它,但字体和页眉和页脚不匹配。我想要与多个文档中相同的格式。有没有办法使样式匹配?