Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.net 提取word文档的内容并插入到另一个word文档中_.net_Vba_Ms Word - Fatal编程技术网

.net 提取word文档的内容并插入到另一个word文档中

.net 提取word文档的内容并插入到另一个word文档中,.net,vba,ms-word,.net,Vba,Ms Word,如何提取没有页眉和页脚的word文档内容,并将其插入具有不同模板(页眉、页边距和页脚不同)的另一个文档中。我可以使用C#或VBA吗?我如何才能做到这一点此行将获取主文档故事(没有页眉、页脚、注释、脚注等),并将其写入另一个文档: targetDocument.Content.FormattedText=sourceDocument.Content.FormattedText 其中targetDocument和sourceDocument是两个Word.Document对象 使用VBA和C#的区别

如何提取没有页眉和页脚的word文档内容,并将其插入具有不同模板(页眉、页边距和页脚不同)的另一个文档中。我可以使用C#或VBA吗?我如何才能做到这一点

此行将获取主文档故事(没有页眉、页脚、注释、脚注等),并将其写入另一个文档:

targetDocument.Content.FormattedText=sourceDocument.Content.FormattedText

其中targetDocument和sourceDocument是两个Word.Document对象


使用VBA和C#的区别主要在于VBA是COM,将在Word.Application中的进程内运行。C#是.NET,将耗尽进程。C#可以与VSTO(加载到Word进程中)一起使用,但也可以通过WinForm、ConsoleApp等使用。您应该使用什么取决于项目其余部分的上下文…

是的,您当然可以使用VBA或C#。请检查Visual Studio工具以获取办公自动化。这个链接。在vba而不是c#或c#而不是vba中这样做的好处是什么