我尝试与
合并Word._Document wordDocument = wordApplication.Documents.Add(
ref templateFileAndPath
, ref missing
, ref missing
, ref missing);
// Make a Word selection object.
Word.Selection selection = wordApplication.Selection;
// Loop thru each of the Word documents
for (int i = 0; i < filesToMerge.Length - 1; i++)
{
string file = filesToMerge[i];
if (file != "")
{
objGenerateDoc.EnqueueAppLog("Merge File " + (i + 1).ToString() + " : " + file.ToString());
// Insert the files to our template
selection.InsertFile(
file
, ref missing
, ref missing
, ref missing
, ref missing);
//Do we want page breaks added after each documents?
if (insertPageBreaks)
{
selection.InsertBreak(ref pageBreak);
}
}
}
wordDocument.SaveAs(
ref outputFile
, ref missing
, ref missing
, ref missing
, ref missing
, ref missing
, ref missing
, ref missing
, ref missing
, ref missing
, ref missing
, ref missing
, ref missing
, ref missing
, ref missing
, ref missing);
我不想将页眉页脚格式合并到其他页面..我需要在这做什么?任何想法?
更新 我尝试用
object DocumentEnd = wordDocument.Content.End - 1;
Range InsertRange = wordDocument.Range(ref DocumentEnd, ref DocumentEnd);
object wdSectionBreakN = WdBreakType.wdSectionBreakNextPage;
InsertRange.InsertBreak(ref wdSectionBreakN);
仍然无法正常工作。它合并了我不想要的所有页眉。