In microsoft word i have created openxml.doc(*.docx) file given credentials 'abc' as Readpassword and 'xyz' as WritePassword.
Now i have to convert openxml.doc to binary.doc(WdSaveFormat=0) the document is created sucessfully as Binary.doc using below code
// Convert OpenXml.doc into binary.doc Convert(@"C:\Test\OpenXml.doc",@"C:\Test\binary.doc",WdSaveFormat.wdFormatDocument);
// Convert a Word .docx to Word 2003 .docpublicstaticvoidConvert(string input,string output,WdSaveFormat format){// Create an instance of Word.exeWord._Application oWord = newWord.Application();
// Make this instance of word invisible (Can still see it in the taskmgr).
oWord.Visible=false;
// Interop requires objects.object oMissing =System.Reflection.Missing.Value;object isVisible =true;object readOnly =false;object oInput = input;object oOutput = output;object oFormat = format;object oNewPassword ="xyz";object oOldPassword ="abc";object test =null;
try{// Load a document into our instance of word.exe// suppose password "abc"Word._Document oDoc = oWord.Documents.Open(ref oInput,ref oMissing,ref readOnly,ref oMissing, oOldPassword,ref oMissing,ref oMissing, oNewPassword,ref oMissing,ref oMissing,ref oMissing,ref isVisible,ref oMissing,ref oMissing,ref oMissing,ref oMissing);
// Make this document the active document.
oDoc.Activate();
// Save this document in Word 2003 format.
oDoc.SaveAs(ref oOutput,ref oFormat,ref oMissing,ref oOldPassword,ref oMissing,
oNewPassword,ref oMissing,ref oMissing,ref oMissing,ref oMissing,ref oMissing,ref oMissing,ref oMissing,ref oMissing,ref oMissing,ref oMissing);Console.WriteLine(test);// Always close Word.exe.
oWord.Quit(ref oMissing,ref oMissing,ref oMissing);}catch(Exception){throw;}}
But when try to open document manually or from code it accepts Readpassword('abc') as shown below
but when tries to give WritePassword('xyz') it doesnt accept and shown password incorrect error.Please check below screenshots
Now i have to convert openxml.doc to binary.doc(WdSaveFormat=0) the document is created sucessfully as Binary.doc using below code
// Convert OpenXml.doc into binary.doc Convert(@"C:\Test\OpenXml.doc",@"C:\Test\binary.doc",WdSaveFormat.wdFormatDocument);
// Convert a Word .docx to Word 2003 .docpublicstaticvoidConvert(string input,string output,WdSaveFormat format){// Create an instance of Word.exeWord._Application oWord = newWord.Application();
// Make this instance of word invisible (Can still see it in the taskmgr).
oWord.Visible=false;
// Interop requires objects.object oMissing =System.Reflection.Missing.Value;object isVisible =true;object readOnly =false;object oInput = input;object oOutput = output;object oFormat = format;object oNewPassword ="xyz";object oOldPassword ="abc";object test =null;
try{// Load a document into our instance of word.exe// suppose password "abc"Word._Document oDoc = oWord.Documents.Open(ref oInput,ref oMissing,ref readOnly,ref oMissing, oOldPassword,ref oMissing,ref oMissing, oNewPassword,ref oMissing,ref oMissing,ref oMissing,ref isVisible,ref oMissing,ref oMissing,ref oMissing,ref oMissing);
// Make this document the active document.
oDoc.Activate();
// Save this document in Word 2003 format.
oDoc.SaveAs(ref oOutput,ref oFormat,ref oMissing,ref oOldPassword,ref oMissing,
oNewPassword,ref oMissing,ref oMissing,ref oMissing,ref oMissing,ref oMissing,ref oMissing,ref oMissing,ref oMissing,ref oMissing,ref oMissing);Console.WriteLine(test);// Always close Word.exe.
oWord.Quit(ref oMissing,ref oMissing,ref oMissing);}catch(Exception){throw;}}
But when try to open document manually or from code it accepts Readpassword('abc') as shown below
but when tries to give WritePassword('xyz') it doesnt accept and shown password incorrect error.Please check below screenshots
Attachments
Last edited by a moderator: