VSTO中的完整word文档副本 [英] Full word document copy in VSTO
本文介绍了VSTO中的完整word文档副本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图在不关闭目标文档的情况下将一个 Word 文档复制到另一个文档.所以,我是这样做的:
I am trying to copy a word document to another without closing the target document. So, I do it like that:
temp_doc_.Content.Copy();
target_doc_.Content.Paste();
temp_doc_.Close(SaveChanges: false);
但是,这不会复制某些功能,例如边距、标题高度等.它只会复制部分段落.有谁知道如何制作完整副本,以便它们在所有方面都完全相同?
However, this doesn't copy some features like margins, header height, ... etc. It only copies section paragraphs. Does anyone know how to do a full copy so that they are really identical in everything ?
推荐答案
我不是 100% 肯定这会做页边距,但它会做页眉和页脚.
I'm not 100% sure this will do the margins, but it WILL do the headers and footers.
Word.Document tempDoc = wordApp.Documents.Open('tempdoc.docx');
Word.Document targetDoc = wordApp.Documents.Open('targetdoc.docx');
tempDoc.Activate();
tempDoc.Application.Selection.WholeStory();
tempDoc.Application.Selection.Copy();
targetDoc.Activate();
targetDoc.Application.Selection.WholeStory();
targetDoc.Application.Selection.PasteAndFormat(Word.WdRecoveryType.wdFormatOriginalFormatting);
这篇关于VSTO中的完整word文档副本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文