请教怎么用C#复制WORD的内容到另外一个WORD中
请问如何用C#复制WORD的内容到另外一个WORD中
有两个Word(WORD1 WORD2)
我想用C#把Word2的内容全部拷到Word1中,请问哪位大虾做过
能发代码看一看吗
------解决方案--------------------
文件的读写?
------解决方案--------------------
用Aspose.Words这个控件试下,百度下可以下到破解版的,比用office带的那几个DLL好用多了。
这个不一定很准确,仅供参考:
Document doc1 = new Document("e:\\test1.doc");
DocumentBuilder builder1 = new DocumentBuilder(doc1);
Document doc2 = new Document("e:\\test2.doc");
DocumentBuilder builder2 = new DocumentBuilder(doc2);
Section sec1 = builder1.CurrentSection;
builder2.CurrentSection.AppendContent(sec1);
doc2.Save("e:\\test2.doc");
------解决方案--------------------
Word操作类 需添加Com引用 对word文件的读写操作全都有
有两个Word(WORD1 WORD2)
我想用C#把Word2的内容全部拷到Word1中,请问哪位大虾做过
能发代码看一看吗
------解决方案--------------------
文件的读写?
------解决方案--------------------
用Aspose.Words这个控件试下,百度下可以下到破解版的,比用office带的那几个DLL好用多了。
这个不一定很准确,仅供参考:
Document doc1 = new Document("e:\\test1.doc");
DocumentBuilder builder1 = new DocumentBuilder(doc1);
Document doc2 = new Document("e:\\test2.doc");
DocumentBuilder builder2 = new DocumentBuilder(doc2);
Section sec1 = builder1.CurrentSection;
builder2.CurrentSection.AppendContent(sec1);
doc2.Save("e:\\test2.doc");
------解决方案--------------------
Word操作类 需添加Com引用 对word文件的读写操作全都有
/***************************************************************************
* word辅助类
* 作者:chengfellow
* 日期:2008.8.18
* 注意事项:
* 1、开发环境居于office 2003;
* 2、需要添加Com引用:Microsoft Office 11.0 Object Library和
* Microsoft Word 11.0 Object Library。
*
****************************************************************************/
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using System.Windows.Forms;
using System.IO;
namespace CodeEncoder
{
public class WordHelp
{
private Microsoft.Office.Interop.Word.ApplicationClass oWordApplic; // a reference to Word application
private Microsoft.Office.Interop.Word.Document oDoc; // a reference to the document
object missing = System.Reflection.Missing.Value;
public Microsoft.Office.Interop.Word.ApplicationClass WordApplication
{
get { return oWordApplic; }
}
public WordHelp()
{
// activate the interface with the COM object of Microsoft Word
oWordApplic = new Microsoft.Office.Interop.Word.ApplicationClass();
}
public WordHelp(Microsoft.Office.Interop.Word.ApplicationClass wordapp)
{
oWordApplic = wordapp;
}
#region 文件操作
// Open a file (the file must exists) and activate it
public void Open(string strFileName)
{
object fileName = strFileName;
object readOnly = false;
object isVisible = true;
oDoc = oWordApplic.Documents.Open(ref fileName, ref missing, ref readOnly,
ref missing, ref missing, ref missing, ref missing, ref missing, ref missing,
ref missing, ref missing, ref isVisible, ref missing, ref missing, ref missing, ref missing);
oDoc.Activate();