簡體   English   中英

復制文檔文件的內容,並將其附加到另一個文件中,使其保持格式化的C#

[英]Copy the content of a document file and append it into another keeping it formatted C#

我想將文檔文件的內容復制到另一個保持格式的文件中。 我找到了一種使用File.Copy(file, newFile, true);將整個文檔復制到新文檔的方法File.Copy(file, newFile, true); 但我需要將內容附加到另一個現有內容中。

這是一個快速的代碼示例,可以幫助您:

using Word = Microsoft.Office.Interop.Word;

var wdApp = new Word.Application();
var documents = wdApp.Documents;
var doc = documents.Open(newFile);
doc.Content.Collapse(Word.WdCollapseDirection.wdCollapseEnd);
doc.Content.InsertFile(file);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM