win32.com problem to unprotect a word document
Peter Hansen
peter at engcorp.com
Mon Nov 10 10:15:57 EST 2003
Christian Lehmann wrote:
>
> I´m trying to unprotect a word document with python for reading all form fields.
> But it doesn´t work.
>
> Here´s a simple code sample:
>
> wordapp = win32com.client.Dispatch("Word.Application")
> docfile = wordapp.Documents.Open(file)
>
> protecttype = docfile.ProtectionType # protected delivers 2
> docfile.Unprotect
> protecttype = docfile.ProtectionType # anyway 2
>
> # do some work
>
> docfile.Protect
> protecttype = docfile.ProtectionType # anyway 2
>
> So someone please tell me, whats my fault?
Is it possible you should actually be *calling* Unprotect
and Protect, instead of just retrieving their values?
To do that, make sure you include the parentheses as in
docfile.Unprotect()
Python is not VB...
-Peter
More information about the Python-list
mailing list