DSO Framer Control Object 操作word文件

<1>DSO Framer Control Object 实现加载word文件的不可编辑

       axFramerControl1.Open(OldPath);

       this.axFramerControl1.set_EnableFileCommand(DSOFramer.dsoFileCommandType.dsoFileSave, false);  //实现嵌入word文件的不可编辑                                        this.axFramerControl1.set_EnableFileCommand(DSOFramer.dsoFileCommandType.dsoFileSaveAs, false);

       Microsoft.Office.Interop.Word.DocumentClass w = (Microsoft.Office.Interop.Word.DocumentClass)this.axFramerControl1.ActiveDocument;

       object missing = false;

       object obj = true;

       object obj2 = "1234";

       w.Protect(Microsoft.Office.Interop.Word.WdProtectionType.wdAllowOnlyReading, ref obj, ref obj2, ref missing, ref obj);

<2>DSO Framer Control Object 实现保存word文件,而不覆盖源文件                                                                     this.axFramerControl1.set_EnableFileCommand(DSOFramer.dsoFileCommandType.dsoFileSaveAs, false);

      Microsoft.Office.Interop.Word.DocumentClass w = (Microsoft.Office.Interop.Word.DocumentClass)this.axFramerControl1.ActiveDocument;

      object filepath = (object)FilePath;

       object mis = Type.Missing;

       w.SaveAs(ref filepath,ref mis,ref mis,ref mis,ref mis, ref mis, ref mis, ref mis, ref mis, ref mis, ref mis, ref mis, ref mis, ref mis, ref mis, ref mis); //另存为

       axFramerControl1.Close();   //关闭,从而不必w.close()

<3>axFramerControl1保存当前word文件

      axFramerControl1.Save(FilePath + filename, true, Type.Missing, Type.Missing);

      save方法定义如下:

      public virtual void Save(Object saveAsDocument, , object overwriteExisting, object webUsername, object webPassword);

        saveAsDocument    要保存的文件名

        overwriteExisting    如果文件已经存在是否覆盖

        webUsername       word设置的密码保护账号

        webPassword        word设置的密码保护密码

posted @ 2015-08-27 00:30  best.lei  阅读(1299)  评论(0编辑  收藏  举报