win32.com problem to unprotect a word document

SBrunning at trisystems.co.uk SBrunning at trisystems.co.uk
Mon Nov 10 09:57:10 EST 2003


> From:	docelm at web.de [SMTP:docelm at web.de]
> 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
 
Just a wild guess - docfile.Unprotect looks like a it might well be a
function, but you aren't *calling* it. Try using "docfile.Unprotect()"
instead.

Cheers,
Simon Brunning,
http://www.brunningonline.net/simon/blog/
--LongSig




-----------------------------------------------------------------------
The information in this email is confidential and may be legally privileged.
It is intended solely for the addressee. Access to this email by anyone else
is unauthorised. If you are not the intended recipient, any disclosure,
copying, distribution, or any action taken or omitted to be taken in
reliance on it, is prohibited and may be unlawful. TriSystems Ltd. cannot
accept liability for statements made which are clearly the senders own.





More information about the Python-list mailing list