win32com: how to connect to a specific instance of a running object?

ago xivulon at
Fri Jun 2 20:40:28 CEST 2006

solved, if it can be useful to others here is my code:

import pythoncom
import win32com.client

def getWorkbook(workbookName):
	lenstr = len(workbookName)
	workbook = None
	rot = pythoncom.GetRunningObjectTable()
	rotenum = rot.EnumRunning()
	while True:
		monikers = rotenum.Next()
		if not monikers: break
		ctx = pythoncom.CreateBindCtx(0)
		name = monikers[0].GetDisplayName(ctx, None);
		if name[-lenstr:] == workbookName:
			obj = rot.GetObject(monikers[0])
			workbook =
	return workbook

More information about the Python-list mailing list