Free Support Forum - aspose.com

How to retain the existing protection password on the word doc?

How to retain the existing protection password on the word doc? I see that Document.Protect method can be used to protect a word doc from changes. However how could I retain the existing protecting password applied earlier?

(Aspose.Words.dll Version: 8.2.0)

Hi,


Thanks for your inquiry. Please use the latest version of Aspose.Words for .NET and use the following code snippet for your requirement.

I suggest you to read following documentation links for your kind reference.
http://www.aspose.com/docs/display/wordsnet/DocSaveOptions+Class
http://www.aspose.com/docs/display/wordsnet/OoxmlSaveOptions+Class

<span style=“font-size:10.0pt;
font-family:“Courier New”;color:#2B91AF;mso-font-kerning:0pt;mso-ansi-language:
PL;mso-no-proof:yes”>LoadOptions<span style=“font-size:10.0pt;
font-family:“Courier New”;mso-font-kerning:0pt;mso-ansi-language:PL;mso-no-proof:
yes”> loadoption = new LoadOptions();<o:p></o:p>

loadoption.Password = "test";

Document doc = new Document(MyDir + "in.doc", loadoption);

DocSaveOptions options = new DocSaveOptions(SaveFormat.Doc);

options.Password = "test";

doc.Save(MyDir + "AsposeOut.doc", options);