<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Using pyWin32 with Excel</title>
	<atom:link href="http://blog.showmedo.com/news/using-pywin32-with-excel/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.showmedo.com/news/using-pywin32-with-excel/</link>
	<description>Building the site, promoting the videos, sharing the knowledge</description>
	<lastBuildDate>Thu, 09 Apr 2009 17:28:39 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=abc</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: ggivler</title>
		<link>http://blog.showmedo.com/news/using-pywin32-with-excel/comment-page-1/#comment-34793</link>
		<dc:creator>ggivler</dc:creator>
		<pubDate>Fri, 11 Apr 2008 20:21:26 +0000</pubDate>
		<guid isPermaLink="false">http://blog.showmedo.com/?p=319#comment-34793</guid>
		<description>I have not had a chance to watch the demo, but here is something I learned doing this.

I do some spreadsheet creation here at work for various departments, so I use a brute force method of finding all instances of EXCEL and killing them, I warn the user about this when the program starts. My programs all have a GUI so they can say no, then shut there excel stuff down before running my program. Here is the code:

import wmi

    def CloseXL(self):
        try:
            if self.xl is not None:
                self.xlBook.Close(SaveChanges=0)
                self.xl.Quit()
                del self.xl
        except AttributeError, err:
            if err[0] != &#039;xl&#039;:
                raise AttributeError, err
            
                
        c = wmi.WMI()
        if not self.NoExcel:
            for process in c.Win32_Process(name=&quot;excel.exe&quot;):
                process.Terminate()</description>
		<content:encoded><![CDATA[<p>I have not had a chance to watch the demo, but here is something I learned doing this.</p>
<p>I do some spreadsheet creation here at work for various departments, so I use a brute force method of finding all instances of EXCEL and killing them, I warn the user about this when the program starts. My programs all have a GUI so they can say no, then shut there excel stuff down before running my program. Here is the code:</p>
<p>import wmi</p>
<p>    def CloseXL(self):<br />
        try:<br />
            if self.xl is not None:<br />
                self.xlBook.Close(SaveChanges=0)<br />
                self.xl.Quit()<br />
                del self.xl<br />
        except AttributeError, err:<br />
            if err[0] != &#8216;xl&#8217;:<br />
                raise AttributeError, err</p>
<p>        c = wmi.WMI()<br />
        if not self.NoExcel:<br />
            for process in c.Win32_Process(name=&#8221;excel.exe&#8221;):<br />
                process.Terminate()</p>
]]></content:encoded>
	</item>
</channel>
</rss>

