How to retrieve the author of an office file in python?

后端 未结 4 1000
情话喂你
情话喂你 2020-11-30 12:58

Title explains the problem, there are doc and docs files that which I want to retrieive their author information so that I can restructure my files.

os.stat

4条回答
  •  醉梦人生
    2020-11-30 13:44

    You can use COM interop to access the Word object model. This link talks about the technique: http://www.blog.pythonlibrary.org/2010/07/16/python-and-microsoft-office-using-pywin32/

    The secret when working with any of the office objects is knowing what item to access from the overwhelming amount of methods and properties. In this case each document has a list of BuiltInDocumentProperties . The property of interest is "Last Author".

    After you open the document you will access the author with something like word.ActiveDocument.BuiltInDocumentProperties("Last Author")

提交回复
热议问题