<br><font size=2 face="sans-serif">Tim,</font>
<br>
<br><font size=2 face="sans-serif">That worked perfectly.</font>
<br>
<br><font size=2 face="sans-serif">Much obliged.</font>
<br>
<br><font size=2 face="sans-serif">Thanks very much,<br>
Tom</font>
<br>
<br>
<br>
<table width=100%>
<tr valign=top>
<td><font size=1 face="sans-serif"><b>"Tim Golden" <tim.golden@viacom-outdoor.co.uk></b>
</font>
<br>
<br><font size=1 face="sans-serif">Sent by: python-win32-bounces@python.org</font>
<p><font size=1 face="sans-serif">06/21/2005 11:52 AM</font>
<td>
<table width=100%>
<tr valign=top>
<td>
<td>
<p>
<tr valign=top>
<td>
<div align=right><font size=1 face="sans-serif">To</font></div>
<td><font size=1 face="sans-serif"><python-win32@python.org></font>
<tr valign=top>
<td>
<div align=right><font size=1 face="sans-serif">cc</font></div>
<td>
<tr valign=top>
<td>
<div align=right><font size=1 face="sans-serif">Subject</font></div>
<td><font size=1 face="sans-serif">Re: [python-win32] Forcing win32com.client.dispatch
to start up a freshExcel</font></table>
<br>
<table>
<tr valign=top>
<td>
<td></table>
<br></table>
<br>
<br>
<br><font size=2><tt>[Tom_RobbinsMilne@swissre.com]<br>
<br>
| I'm trying to use Python's win32com interface to drive an excel spreadsheet.
<br>
<br>
| I've managed to have it open the sheet, call a VBA function with arguments,
and close it down cleanly. <br>
<br>
| However, if Excel is already running, it closes the open instance. Which
is not good. <br>
<br>
| Is there a way I can do the equivalent of VBA's CreateObject() with win32com?
I have purchased <br>
| "Python Programming on | Win32", and can't find anything. <br>
<br>
I'm not sure about the CreateObject bit, not being a<br>
VBA person, but I suspect you may want to use the<br>
DispatchEx method rather than simply Dispatch. eg,<br>
<br>
[some spreadsheet already open]<br>
<br>
<code><br>
import win32com.client<br>
<br>
xl = win32com.client.DispatchEx ("Excel.Application")<br>
wb = xl.Workbooks.Add ()<br>
ws = xl.ActiveSheet<br>
<br>
ws.Cells (1, 1).Value = "Hello"<br>
<br>
wb.SaveAs ("c:/temp/temp.xls")<br>
wb.Close ()<br>
xl.Quit ()<br>
<br>
xl = None<br>
</code><br>
<br>
[original spreadsheet still open]<br>
<br>
TJG<br>
<br>
________________________________________________________________________<br>
This e-mail has been scanned for all viruses by Star. The<br>
service is powered by MessageLabs. For more information on a proactive<br>
anti-virus service working around the clock, around the globe, visit:<br>
http://www.star.net.uk<br>
________________________________________________________________________<br>
_______________________________________________<br>
Python-win32 mailing list<br>
Python-win32@python.org<br>
http://mail.python.org/mailman/listinfo/python-win32<br>
</tt></font>
<br>
<font face="Helv" size=3 color=#000000 ></font><br><font face="Helv" size=3 color=#000000 ></font><br><font face="Helv" size=3 color=#000000 ></font><br><font face="Helv" size=3 color=#000000 >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</font><br>