def COMOpen(progID, events=None): try: if events == None: return win32com.client.Dispatch(progID) else: return win32com.client.DispatchWithEvents(progID, events) except: error.abortCheck() error.traceback() return None
def getFromFile(filename): props = docProps() try: props.fileOwner = fileOwner(filename) except: error.abortCheck() props.fileOwner = None stg = wincom.StgOpenStorage( filename, None, wincom.storagecon.STGM_READ | wincom.storagecon.STGM_SHARE_EXCLUSIVE) pss = stg.QueryInterface(wincom.IID_IPropertySetStorage) ps = pss.Open(FMTID_SummaryInformation) data = ps.ReadMultiple(allSummaryInformation) props.path = filename props.title = unicodeFix(data[0]) props.author = unicodeFix(data[2]) props.subject = unicodeFix(data[1]) props.keywords = unicodeFix(data[3]) props.comments = unicodeFix(data[4]) props.template = unicodeFix(data[5]) props.lastAuthor = unicodeFix(data[6]) props.revNumber = unicodeFix(data[7]) props.lastEditTime = PyTime2datetime(data[8]) props.lastPrintedTime = PyTime2datetime(data[9]) props.createdTime = PyTime2datetime(data[10]) props.lastSavedTime = PyTime2datetime(data[11]) props.pageCount = data[12] props.wordCount = data[13] props.charCount = data[14] props.appName = unicodeFix(data[15]) props.docSecurity = data[16] try: ps = pss.Open(FMTID_DocSummaryInformation) data = ps.ReadMultiple([PIDDSI_COMPANY]) # except pythoncom.com_err: No workum, use plain except instead. Sigh. except: error.abortCheck() error.traceback() data = [""] props.company = unicodeFix(data[0]) return props
def getFromFile(filename): props = docProps() try: props.fileOwner = fileOwner(filename) except: error.abortCheck() props.fileOwner = None stg = wincom.StgOpenStorage(filename, None, wincom.storagecon.STGM_READ | wincom.storagecon.STGM_SHARE_EXCLUSIVE) pss = stg.QueryInterface(wincom.IID_IPropertySetStorage) ps = pss.Open(FMTID_SummaryInformation) data = ps.ReadMultiple(allSummaryInformation) props.path = filename props.title = unicodeFix(data[0]) props.author = unicodeFix(data[2]) props.subject = unicodeFix(data[1]) props.keywords = unicodeFix(data[3]) props.comments = unicodeFix(data[4]) props.template = unicodeFix(data[5]) props.lastAuthor = unicodeFix(data[6]) props.revNumber = unicodeFix(data[7]) props.lastEditTime = PyTime2datetime(data[8]) props.lastPrintedTime = PyTime2datetime(data[9]) props.createdTime = PyTime2datetime(data[10]) props.lastSavedTime = PyTime2datetime(data[11]) props.pageCount = data[12] props.wordCount = data[13] props.charCount = data[14] props.appName = unicodeFix(data[15]) props.docSecurity = data[16] try: ps = pss.Open(FMTID_DocSummaryInformation) data = ps.ReadMultiple([PIDDSI_COMPANY]) # except pythoncom.com_err: No workum, use plain except instead. Sigh. except: error.abortCheck() error.traceback() data = [""] props.company = unicodeFix(data[0]) return props