zoukankan      html  css  js  c++  java
  • 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设置的密码保护密码

  • 相关阅读:
    滑动窗口(单调队列)
    蒜头君的排序
    P2024 食物链
    STL
    P2880 [USACO07JAN]平衡的阵容Balanced Lineup(RMQ的倍增模板)
    LCA的两种写法
    P1439 最长公共子序列(nlognLCS问题)
    P3383 【模板】线性筛素数
    P2158 [SDOI2008] 仪仗队(欧拉函数模板)
    alifhab
  • 原文地址:https://www.cnblogs.com/zhanglei93/p/4762108.html
Copyright © 2011-2022 走看看