win32.com problem to unprotect a word document

Christian Lehmann docelm at web.de
Mon Nov 10 09:46:37 EST 2003


Hello,

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? 

best regards
Christian




More information about the Python-list mailing list