cancel
Showing results for 
Search instead for 
Did you mean: 

Word Document password protected

ManojKumar3
Level 6
Hi Team, do we have any VBO action where we can make a word file a password protected document ?? i need to send the document via mail as password protected document    Thanks
2 REPLIES 2

Mustafa_UlasYig
Level 6
Hi Manojt You can duplicate the MS Word VBO action ""Save As"" and create your own action ""Save as Password Protected"" or create your own BO with the following code:  Dim doc as Object = GetDocument(handle,documentname) Dim psword  As Object  psword = ""abcdefg"" (or whatever password you want to set, this could also be a data item input to your code stage) doc.Protect(Microsoft.Office.Interop.Word.WdProtectionType.wdAllowOnlyFormFields)  doc.SaveAs(filename, Password:=psword)  newname = doc.name Where you add the bold vb.net code. Remember to add the ""Microsoft.Office.Interop.Word.dll"" in External references/namespace import section of Business Object Properties's Code options tab. These are the different protection-types that you have in the WdProtectionType method: https://docs.microsoft.com/en-us/dotnet/api/microsoft.office.interop.word.wdprotectiontype?view=word-pia N.B. Once having set the password protect via above code, even if you unlock and remove the password protection from the document, you cannot reset the password protection with above code again. Though I'm sure you can solve this programmatically somehow... Good luck. BR, Mustafa

ManojKumar3
Level 6
Hi Mustafa,   Thanks for your information.  Even i have made a customize code for the existing ""Save as"" äction where we all need to do is just send password as one of the parameter for that save as method in the existing vbo       Dim doc as Object = GetDocument(handle,documentname)     doc.SaveAs(filename,,,password,,password,enforceStyleLock)     newname = doc.name