控制word只读

网上朋友的

if(ThisApplication.ActiveDocument.ProtectionType==WdProtectionType.wdAllowOnlyComments)  
  {  
  ThisApplication.ActiveDocument.Unprotect(ref   Password);  
  }  
   
   
  if(ThisApplication.ActiveDocument.ProtectionType==WdProtectionType.wdNoProtection)  
  {  
  ThisApplication.ActiveDocument.Protect(WdProtectionType.wdAllowOnlyComments,ref   NoResrt   ,ref   Password);  
  }

 

自己实验成果的代码{  axFramerControl1 此为dsoFramer控件 }

this.axFramerControl1.Open("F://aaa1s1.docx");

//
            this.axFramerControl1.set_EnableFileCommand(DSOFramer.dsoFileCommandType.dsoFileSave, false);
            this.axFramerControl1.set_EnableFileCommand(DSOFramer.dsoFileCommandType.dsoFileSaveAs, false);


            this.axFramerControl1.Toolbars = false;
            this.axFramerControl1.Titlebar = false;
            Microsoft.Office.Interop.Word.DocumentClass w = (Microsoft.Office.Interop.Word.DocumentClass)this.axFramerControl1.ActiveDocument;
            object obj1 = true; 
            object obj2 = "aaaaasdfa"; //此为保护密码
            object obj3 = false;
            object obj4 = true;
            w.Protect(Microsoft.Office.Interop.Word.WdProtectionType.wdAllowOnlyReading, ref obj1, ref obj2, ref obj3, ref obj4);

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值