有两个Word(WORD1 WORD2)
我想用C#把Word2的内容全部拷到Word1中,请问哪位大虾做过
能发代码看一看吗
我想用C#把Word2的内容全部拷到Word1中,请问哪位大虾做过
能发代码看一看吗
解决方案 »
- 移除动态添加的控件,移除为最后一个控件且为一组的,请前辈指点!
- 想做移动应用程序开发,想学windows phone 7方面的开发,但不知到有没有前途啊!大家给个意见啊!我是学生啊!大哥大姐,帮个忙啊!
- 第1次写递归,现学现卖,大家帮我看看对了没
- 为什么不能跳转页面!
- 鼠标滚轮事件
- 请问在水晶报表中如何实现如下格式?
- C#与数据库SQL 高手
- SOS,C#中判断Excel文件是否被打开的问题
- 问个关于winfrom中datagridview 删除列的问题 ..
- 自己写的代码无法读取某网站的rss,用浏览器确可以打开,其他网站rss都是正常的
- winfrom 如何实现vs2010伸缩框架结构
- C#中switch语句每个case是不是都需要break?
/// <summary>
/// 拷贝密封线Word
/// </summary>
/// <param name="strPath"></param>
private void GetWordContent(object strPath)
{
object strSealWordPath = @"F:\SealWord.docx";
Microsoft.Office.Interop.Word.Application WordAppCopy = null;
Microsoft.Office.Interop.Word.Document WordDocCopy = null;
Microsoft.Office.Interop.Word.Application WordAppPaste = null;
Microsoft.Office.Interop.Word.Document WordDocPaste = null;
Object Nothing = System.Reflection.Missing.Value;
string str = string.Empty;
try
{
WordAppCopy = new Microsoft.Office.Interop.Word.ApplicationClass();
WordDocCopy = WordAppCopy.Documents.Open(ref strSealWordPath, ref Nothing, ref Nothing, ref Nothing,
ref Nothing, ref Nothing, ref Nothing, ref Nothing,
ref Nothing, ref Nothing, ref Nothing, ref Nothing,
ref Nothing, ref Nothing, ref Nothing, ref Nothing);
WordDocCopy.ActiveWindow.Selection.WholeStory();
WordDocCopy.ActiveWindow.Selection.Copy(); WordAppPaste = new Microsoft.Office.Interop.Word.ApplicationClass();
WordDocPaste = WordAppPaste.Documents.Open(ref strPath, ref Nothing, ref Nothing, ref Nothing,
ref Nothing, ref Nothing, ref Nothing, ref Nothing,
ref Nothing, ref Nothing, ref Nothing, ref Nothing,
ref Nothing, ref Nothing, ref Nothing, ref Nothing);
WordDocPaste.PageSetup.PaperSize = Microsoft.Office.Interop.Word.WdPaperSize.wdPaperA3;
WordDocPaste.ActiveWindow.Selection.Paste();
WordDocPaste.Save();
}
catch
{ }
finally
{
if (WordDocCopy != null)
{
Marshal.ReleaseComObject(WordDocCopy);
WordDocCopy = null;
}
WordAppCopy.NormalTemplate.Saved = true;
WordAppCopy.Quit(ref Nothing, ref Nothing, ref Nothing); if (WordDocPaste != null)
{
Marshal.ReleaseComObject(WordDocPaste);
WordDocPaste = null;
}
WordAppPaste.NormalTemplate.Saved = true;
WordAppPaste.Quit(ref Nothing, ref Nothing, ref Nothing);
}
}
#endregion