网上朋友的
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);