Hello,
I create a new docx file. Following parts are protected:
oWordDoc.Sections[1].ProtectedForForms = false;
oWordDoc.Sections[2].ProtectedForForms = true;
oWordDoc.Sections[3].ProtectedForForms = false;
object szPassword = "123";
object bFalse = false;
object bTrue = false;
oWordDoc.Protect(WdProtectionType.wdAllowOnlyFormFields, ref bFalse, ref szPassword, ref bFalse, ref bTrue);
The following function is for open the file:
public void OpenDocument(string sfileName)
{
object missing = System.Reflection.Missing.Value;
object oTrue = true;
object oFalse = false;
object objFalse = false;
object worddocument = sfileName;
oWordDoc = oWord.Documents.Open(ref worddocument, ref missing, ref objFalse, ref missing,
ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref objFalse,
ref missing, ref missing, ref missing, ref missing);
oWordDoc.Activate();
}
After the method i want to unprotect the protected sections:
object szPassword = "123";
oWordDoc.Unprotect(ref szPassword);
Here i get the message:
-2146823683 the unprotect method property is not available for reading