0

I have the code:

import win32com.client as com_obj

if __name__ == "__main__":
    word_app = com_obj.Dispatch("Word.Application")
    word_app.Visible = True
    word_doc = word_app.Documents.Open(file_path)
    word_doc.CustomDocumentProperties.Add("100percent_new_property", False, 1, "100percent_new_property_value")

the script return exception:

    word_doc.CustomDocumentProperties.Add("100percent_new_property", False, 1, "100percent_new_property_value")
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<COMObject <unknown>>", line 2, in Add
pywintypes.com_error: (-2147352567, 'Ошибка.', (0, None, None, None, 0, -2147352571), 4)

everything is ok, when I read properties. Where am i wrong? Or what should i check (dcom setting, ms office bitness, etc)?

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.