[Tutor] xtended document properties (dsofile.dll)

Albert-Jan Roskam fomcl at yahoo.com
Fri Dec 2 20:10:53 CET 2011


Hello,

I'd like to read extended document properties using the OLE file property reader (dsofile.dll).
I know it's also possible with pywin32, but we don't have that in our office.

http://support.microsoft.com/kb/224351

http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=8422

I'd like to extract the Last Author property from a whole bunch of xls files but I am failing in the earliest stages.

Using the VB code below, can anybody give me some pointers for the Python code?
import  cstypes, os

os.chdir(os.path.abspath("."))
dso = ctypes.windll.dsofile
print dso.DSOFile.OleDocumentProperties # Error!

Her's the VB code I grabbed from the internet somewhere:

        Dimfilename AsString= "c:\test.doc"
        Dimdso AsDSOFile.OleDocumentProperties
        dso = NewDSOFile.OleDocumentProperties
        dso.Open(filename.Trim, True, 
 
        DSOFile.dsoFileOpenOptions.dsoOptionOpenReadOnlyIfNoWriteAccess)
        Console.WriteLine(dso.SummaryProperties.Author)
        Console.WriteLine(dso.SummaryProperties.ByteCount)
        Console.WriteLine(dso.SummaryProperties.CharacterCount)
        Console.WriteLine(dso.SummaryProperties.CharacterCountWithSpaces)
        Console.WriteLine(dso.SummaryProperties.Comments)
        Console.WriteLine(dso.SummaryProperties.Company)
        Console.WriteLine(dso.SummaryProperties.DateCreated)
        Console.WriteLine(dso.SummaryProperties.DateLastSaved)
        Console.WriteLine(dso.SummaryProperties.LastSavedBy)
        Console.WriteLine(dso.SummaryProperties.LineCount)
        Console.WriteLine(dso.SummaryProperties.PageCount)
        Console.WriteLine(dso.SummaryProperties.ParagraphCount)
        Console.WriteLine(dso.SummaryProperties.RevisionNumber)
        Console.WriteLine(dso.SummaryProperties.Subject)
        Console.WriteLine(dso.SummaryProperties.Title)        Console.WriteLine(dso.SummaryProperties.WordCount)

Thank you in advance!


Cheers!!
Albert-Jan


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
All right, but apart from the sanitation, the medicine, education, wine, public order, irrigation, roads, a fresh water system, and public health, what have the Romans ever done for us?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20111202/1e320c0d/attachment-0001.html>


More information about the Tutor mailing list