OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

How can I determine whether a Word document has a password?

  • Thread starter Thread starter WhoamI
  • Start date Start date
W

WhoamI

Guest
I am trying to read word documents using Python. However, I am stuck in places where the document is password protected, as I do not have the password for the file(s).

How can I detect if the file has password, so can I ignore such files from opening?

Currently, the below code opens a dialog/prompt window in MS-Word to enter the password and keeps waiting for a response.

Code:
word = win32.gencache.EnsureDispatch('Word.Application')
doc = word.Documents.Open(r"D:\appointment\PasswordProtectedDoc.doc")
<p>I am trying to read word documents using Python. However, I am stuck in places where the document is password protected, as I do not have the password for the file(s).</p>
<p>How can I detect if the file has password, so can I ignore such files from opening?</p>
<p>Currently, the below code opens a dialog/prompt window in MS-Word to enter the password and keeps waiting for a response.</p>
<pre><code>word = win32.gencache.EnsureDispatch('Word.Application')
doc = word.Documents.Open(r"D:\appointment\PasswordProtectedDoc.doc")
</code></pre>
 

Latest posts

I
Replies
0
Views
1
impact christian
I
Top