• 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设置的密码保护密码

  • 相关阅读:
    Kubernetes+Federation打造跨多云管理服务
    idou老师教你学istio 31:Istio-proxy的report流程
    《软件工程》课程总结(补)
    《软件工程》课程总结
    十二周# 学习进度总结
    十一周# 学习进度总结
    十周# 学习进度总结
    九周# 学习进度总结
    八周# 学习进度总结
    团队项目——编写项目的Spec
  • 原文地址:https://www.cnblogs.com/zhanglei93/p/4762108.html
Copyright © 2020-2023  润新知