Tim,

That worked perfectly.

Much obliged.

Thanks very much,
Tom



"Tim Golden" <[EMAIL PROTECTED]>

Sent by: [EMAIL PROTECTED]

06/21/2005 11:52 AM

To
<python-win32@python.org>
cc
Subject
Re: [python-win32] Forcing win32com.client.dispatch to start up a        freshExcel





[EMAIL PROTECTED]

| I'm trying to use Python's win32com interface to drive an excel spreadsheet.

| I've managed to have it open the sheet, call a VBA function with arguments, and close it down cleanly.

| However, if Excel is already running, it closes the open instance. Which is not good.

| Is there a way I can do the equivalent of VBA's CreateObject() with win32com? I have purchased
| "Python Programming on | Win32", and can't find anything.

I'm not sure about the CreateObject bit, not being a
VBA person, but I suspect you may want to use the
DispatchEx method rather than simply Dispatch. eg,

[some spreadsheet already open]

<code>
import win32com.client

xl = win32com.client.DispatchEx ("Excel.Application")
wb = xl.Workbooks.Add ()
ws = xl.ActiveSheet

ws.Cells (1, 1).Value = "Hello"

wb.SaveAs ("c:/temp/temp.xls")
wb.Close ()
xl.Quit ()

xl = None
</code>

[original spreadsheet still open]

TJG

________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________
_______________________________________________
Python-win32 mailing list
Python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32




This e-mail, including attachments, is intended for the person(s) or company named and may contain confidential and/or legally privileged information. Unauthorized disclosure, copying or use of this information may be unlawful and is prohibited. If you are not the intended recipient, please delete this message and notify the sender
_______________________________________________
Python-win32 mailing list
Python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32

Reply via email to