We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Password Protection of Word Documents

Hello!

I would like to clone an MS Word document with a new name AND password protect it.
I need the user to be prompted for the password when they attempt to open it.

The following code works (without password protection).

------------------------
Dim sourceDoc As WordDocument = New WordDocument()
sourceDoc.Open(sSourceFile, FormatType.Doc)

Dim doc As WordDocument = New WordDocument()
doc.EnsureMinimal()

doc = sourceDoc.Clone()
doc.Save(sDestFile, FormatType.Doc)

------------------------

The following code gives an error on line 3.
"Cannot open storage. File Name is: C:\abc\xyz.doc"

------------------------
Dim sourceDoc As WordDocument = New WordDocument()
sourceDoc.Open(sSourceFile, FormatType.Doc)

Dim doc As WordDocument = New WordDocument(sDestFile, "password")
doc.EnsureMinimal()

doc = sourceDoc.Clone()
doc.ProtectionType = ProtectionType.AllowOnlyFormFields

doc.Save(sDestFile, FormatType.Doc)

------------------------

Also, the avalable options for ProtectionType do not include one to
prompt the user for a password when they attempt to open the doc file.

Please help!
Thanks!
Howard



1 Reply

AD Administrator Syncfusion Team March 7, 2008 06:55 AM UTC

Hi Howard,

Thank you for your interest in Syncfusion products.

protect the word document by providing password.

The "Password" property of the class "WordDocument" is not a protection password - it is the password to open the document.
We can able to set only protection type of the document. The protection password is not supported by DocIO. We have already created feature request regarding this and We do not have immediate plan for implementing this feature in the near future.

Sorry for the onconvenience.

Please let me know if you have any questions.

Best Regards,
Bhuvana



Loader.
Live Chat Icon For mobile
Up arrow icon