Word Document password protected
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
24-08-18 03:48 PM
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
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
27-08-18 05:01 PM
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
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
28-08-18 03:09 PM
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
