1

I have the following lines of code in a .py script and I am accessing a password protected document. However, when this script runs Word asks for the password again from the user once winword.exe is visible. Is this normal behavior? I am doubtful since it asks for the password whether or not I include it in my .py file. Any input is appreciated. Following is the code:

word=win32com.client.Dispatch('Word.Application')
word.Visible=1
doc=word.Documents.Open('FilePath',PasswordDocument='PASSWORD')

On a side note, the goal is that the .docx must only be accessible via this script (which opens Word) and nothing else. Any alternate method anyone else has in mind for implementing this will also be appreciated.

Deduplicator
  • 44,692
  • 7
  • 66
  • 118
user262716
  • 17
  • 1
  • To your actual question, perhaps do ```word.Visible=1``` after opening the doc? As for the side note, if you want security, [python is less than ideal](http://stackoverflow.com/questions/261638/how-do-i-protect-python-code) for doing it. Could you elaborate a little more on what you want to do with the document? – wnnmaw Jun 25 '14 at 21:08
  • just tried adding word.Visible=1 after opening..didn't change anything..well I won't actually use the .py script I'll compile it to .exe once it works..Am I using the correct argument here? What I want to do is that the document file should go through my application to be accessed. I thought by adding a password (whose password only my program knew) would do the trick. But since it is asking again when Word opens, it leaves me where I started from. – user262716 Jun 25 '14 at 21:15
  • btw..Is asking for the password again the default behavior? Couldn't find anything on it online :( – user262716 Jun 25 '14 at 21:21

0 Answers0