文档加水印的方法 。但运行报下面错误 请教
public void show()
{
object Nothing = System.Reflection.Missing.Value;
Word.ApplicationClass wordAppObj = null; Word.Document WordDoc = null; try
{
// object srcFileName = Server.MapPath("Documnets") + "/ProjectTmp.doc";
// object dstFileName = Server.MapPath("Documnets") + "/Project.doc";
string FileName = Server.MapPath("~/UpLoad") + "/water.gif"; object srcFileName = "C:\\公司框架.doc"; object dstFileName = "C:\\公司框架.doc"; object obj = true; wordAppObj = new Word.ApplicationClass(); WordDoc = wordAppObj.Documents.Open(ref srcFileName, 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);
this.CreateWaterMarkImg("与电子文本一致", WordDoc.ActiveWindow.Height, WordDoc.ActiveWindow.Width, WordDoc.ActiveWindow.Width, WordDoc.ActiveWindow.Height);
Word.Shape oShape; WordDoc.ActiveWindow.View.Type = Word.WdViewType.wdOutlineView; WordDoc.ActiveWindow.View.SeekView = Word.WdSeekView.wdSeekPrimaryHeader; // WordDoc.ActiveWindow.ActivePane.Selection.InsertAfter(DateTime.Now.ToString("yyyyMMddhhssmm")); object top = 36; oShape = WordDoc.ActiveWindow.ActivePane.Selection.HeaderFooter.Shapes.AddPicture(FileName, ref Nothing, ref Nothing, ref Nothing, ref top, ref Nothing, ref Nothing, ref Nothing); oShape.WrapFormat.Type = Word.WdWrapType.wdWrapInline; oShape.ZOrder(Microsoft.Office.Core.MsoZOrderCmd.msoSendBehindText); WordDoc.SaveAs(ref dstFileName, 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);
} catch (Exception ex)
{
} finally
{ WordDoc.Close(ref Nothing, ref Nothing, ref Nothing); wordAppObj.Quit(ref Nothing, ref Nothing, ref Nothing); }
}编译器错误消息: CS0012: 类型“Microsoft.Office.Core.MsoZOrderCmd”在未被引用的程序集中定义。必须添加对程序集“Interop.Microsoft.Office.Core, Version=2.3.0.0, Culture=neutral, PublicKeyToken=null”的引用。行 262: oShape.ZOrder(Microsoft.Office.Core.MsoZOrderCmd.msoSendBehindText);
public void show()
{
object Nothing = System.Reflection.Missing.Value;
Word.ApplicationClass wordAppObj = null; Word.Document WordDoc = null; try
{
// object srcFileName = Server.MapPath("Documnets") + "/ProjectTmp.doc";
// object dstFileName = Server.MapPath("Documnets") + "/Project.doc";
string FileName = Server.MapPath("~/UpLoad") + "/water.gif"; object srcFileName = "C:\\公司框架.doc"; object dstFileName = "C:\\公司框架.doc"; object obj = true; wordAppObj = new Word.ApplicationClass(); WordDoc = wordAppObj.Documents.Open(ref srcFileName, 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);
this.CreateWaterMarkImg("与电子文本一致", WordDoc.ActiveWindow.Height, WordDoc.ActiveWindow.Width, WordDoc.ActiveWindow.Width, WordDoc.ActiveWindow.Height);
Word.Shape oShape; WordDoc.ActiveWindow.View.Type = Word.WdViewType.wdOutlineView; WordDoc.ActiveWindow.View.SeekView = Word.WdSeekView.wdSeekPrimaryHeader; // WordDoc.ActiveWindow.ActivePane.Selection.InsertAfter(DateTime.Now.ToString("yyyyMMddhhssmm")); object top = 36; oShape = WordDoc.ActiveWindow.ActivePane.Selection.HeaderFooter.Shapes.AddPicture(FileName, ref Nothing, ref Nothing, ref Nothing, ref top, ref Nothing, ref Nothing, ref Nothing); oShape.WrapFormat.Type = Word.WdWrapType.wdWrapInline; oShape.ZOrder(Microsoft.Office.Core.MsoZOrderCmd.msoSendBehindText); WordDoc.SaveAs(ref dstFileName, 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);
} catch (Exception ex)
{
} finally
{ WordDoc.Close(ref Nothing, ref Nothing, ref Nothing); wordAppObj.Quit(ref Nothing, ref Nothing, ref Nothing); }
}编译器错误消息: CS0012: 类型“Microsoft.Office.Core.MsoZOrderCmd”在未被引用的程序集中定义。必须添加对程序集“Interop.Microsoft.Office.Core, Version=2.3.0.0, Culture=neutral, PublicKeyToken=null”的引用。行 262: oShape.ZOrder(Microsoft.Office.Core.MsoZOrderCmd.msoSendBehindText);
解决方案 »
- Npoi 读取excel背景色转成html可认的信息
- 问个简单的问题,谢谢
- --------关于 blog 的思路,建议有分 ----------
- 在gridview中关于数据绑定后显示的数据的问题。急~~~~~~~~~~~~
- 请问一下大家,使用代理服务器会被发现吗?比如,我浏览别人网站,别人知道我用的是代理器吗
- 关于写日志
- 怎样用一个事件处理函数处理一个页面的多个button?
- ::用DataList控件每行显示5条记录时,如何让各记录宽度相等???::
- 在DataGrid中怎么获得Edititem那一栏中textbox中的数据?
- 如何在datagrid中的一列写入两个数据库中的字段
- 新浪的这种列表是如何实现的
- 为什么数据没有写到Access数据库中?
百度找Microsoft.Office.CoreMicrosoft.Office.Core 添加引用