首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

CS0012: 门类“Microsoft.Office.Core.MsoZOrderCmd”在未被引用的程序集中定义

2013-07-20 
CS0012: 类型“Microsoft.Office.Core.MsoZOrderCmd”在未被引用的程序集中定义文档加水印的方法 。但运行报

CS0012: 类型“Microsoft.Office.Core.MsoZOrderCmd”在未被引用的程序集中定义
文档加水印的方法 。但运行报下面错误 请教。。。


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);
------解决方案--------------------


那你添加一下对相应dll文件的引用不就行了。。。
[解决办法]
就是添加引用有问题。。。。


百度找Microsoft.Office.CoreMicrosoft.Office.Core 添加引用

热点排行