Python, COM and Threads
stephentubbs
member at dbforums.com
Thu Oct 31 12:32:32 EST 2002
I am currently struggling with a similar situation under Python 2.1.
I've included a bit of sample code to illustrate. To summarize, I am
creating a thread that creates a connection to Excel and attempts to
write to the worksheet.
from threading import Thread
class foo:
def run(self):
try:
import win32com.client
self.excel = win32com.client.Dispatch("Excel.Application")
self.excel.Visible = 1
k = self.excel.Workbooks.Add()
v = k.Worksheets(1)
v.Cells(1,1).Value = str(self)
except:
import traceback
traceback.print_exc()
l = Thread(target = foo().run, #creates a new instance
name = 'foo',verbose = 1)
l.start()
Any suggestions would be greatly appreciated.
Stephen
--
Posted via http://dbforums.com
More information about the Python-list
mailing list