<?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: How To Kill MS Excel Process Started by ASP.NET</title>
	<atom:link href="http://sodeve.net/how-to-kill-ms-excel-process-started-by-aspnet/feed/" rel="self" type="application/rss+xml" />
	<link>http://sodeve.net/how-to-kill-ms-excel-process-started-by-aspnet/</link>
	<description>is a software developer&#60;br&#62;in a pursuit of happyness</description>
	<lastBuildDate>Fri, 16 Jul 2010 18:44:01 -0700</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Hardono Arifanto</title>
		<link>http://sodeve.net/how-to-kill-ms-excel-process-started-by-aspnet/comment-page-1/#comment-1467</link>
		<dc:creator>Hardono Arifanto</dc:creator>
		<pubDate>Wed, 14 Jan 2009 13:53:47 +0000</pubDate>
		<guid isPermaLink="false">http://sodeve.net/how-to-kill-ms-excel-process-started-by-aspnet/#comment-1467</guid>
		<description>@Adam: Cool trick :)</description>
		<content:encoded><![CDATA[<p>@Adam: Cool trick <img src='http://sodeve.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: adam</title>
		<link>http://sodeve.net/how-to-kill-ms-excel-process-started-by-aspnet/comment-page-1/#comment-1464</link>
		<dc:creator>adam</dc:creator>
		<pubDate>Tue, 13 Jan 2009 11:13:30 +0000</pubDate>
		<guid isPermaLink="false">http://sodeve.net/how-to-kill-ms-excel-process-started-by-aspnet/#comment-1464</guid>
		<description>Im afraid this doesn&#039;t appear to be working when using excel 2003.

It seems that all the excel.exe processes share the same Hinstance.

This happens to me with excel opened before and after my application starts with this code.

I have a different approach which isn&#039;t 100% but closes the correct excel application.


***
When creating the excel application instance i make a note of the time before and after the instance is created

    Dim xlApplication As Application
    Dim xlApplicationStartTime1 As DateTime
    Dim xlApplicationStartTime2 As DateTime

    xlApplicationStartTime1 = DateTime.Now()
    xlApplication = New Application
    xlApplicationStartTime2 = DateTime.Now()


&#039;&#039; For the kill process, I check the StartTime of the process

        For Each p As Process In Process.GetProcessesByName(&quot;EXCEL&quot;)

            If p.StartTime &gt;= xlApplicationStartTime1 And p.StartTime </description>
		<content:encoded><![CDATA[<p>Im afraid this doesn&#8217;t appear to be working when using excel 2003.</p>
<p>It seems that all the excel.exe processes share the same Hinstance.</p>
<p>This happens to me with excel opened before and after my application starts with this code.</p>
<p>I have a different approach which isn&#8217;t 100% but closes the correct excel application.</p>
<p>***<br />
When creating the excel application instance i make a note of the time before and after the instance is created</p>
<p>    Dim xlApplication As Application<br />
    Dim xlApplicationStartTime1 As DateTime<br />
    Dim xlApplicationStartTime2 As DateTime</p>
<p>    xlApplicationStartTime1 = DateTime.Now()<br />
    xlApplication = New Application<br />
    xlApplicationStartTime2 = DateTime.Now()</p>
<p>&#8221; For the kill process, I check the StartTime of the process</p>
<p>        For Each p As Process In Process.GetProcessesByName(&#8221;EXCEL&#8221;)</p>
<p>            If p.StartTime &gt;= xlApplicationStartTime1 And p.StartTime</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Hardono Arifanto</title>
		<link>http://sodeve.net/how-to-kill-ms-excel-process-started-by-aspnet/comment-page-1/#comment-1425</link>
		<dc:creator>Hardono Arifanto</dc:creator>
		<pubDate>Wed, 17 Dec 2008 16:45:33 +0000</pubDate>
		<guid isPermaLink="false">http://sodeve.net/how-to-kill-ms-excel-process-started-by-aspnet/#comment-1425</guid>
		<description>@Ata: Cheers mate! :)</description>
		<content:encoded><![CDATA[<p>@Ata: Cheers mate! <img src='http://sodeve.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ata Turkoglu</title>
		<link>http://sodeve.net/how-to-kill-ms-excel-process-started-by-aspnet/comment-page-1/#comment-1424</link>
		<dc:creator>Ata Turkoglu</dc:creator>
		<pubDate>Mon, 15 Dec 2008 09:36:53 +0000</pubDate>
		<guid isPermaLink="false">http://sodeve.net/how-to-kill-ms-excel-process-started-by-aspnet/#comment-1424</guid>
		<description>Thank you so much Sodeve,

This little part of code you wrote has saved my life. I really digged inside many different ebooks or even inside msdn and couldn&#039;t find this simple solution.

The same solution for word (if needed):

foreach (Process p in Process.GetProcessesByName(&quot;WINWORD&quot;))   
{   
    int baseAdd = p.MainModule.BaseAddress.ToInt32();   

    //oXL is Excel.ApplicationClass object   
    if (baseAdd == oXL.Hinstance)   
        p.Kill();   
}  

Many thanks again.. god bless you my friend..

Ata..</description>
		<content:encoded><![CDATA[<p>Thank you so much Sodeve,</p>
<p>This little part of code you wrote has saved my life. I really digged inside many different ebooks or even inside msdn and couldn&#8217;t find this simple solution.</p>
<p>The same solution for word (if needed):</p>
<p>foreach (Process p in Process.GetProcessesByName(&#8221;WINWORD&#8221;))<br />
{<br />
    int baseAdd = p.MainModule.BaseAddress.ToInt32();   </p>
<p>    //oXL is Excel.ApplicationClass object<br />
    if (baseAdd == oXL.Hinstance)<br />
        p.Kill();<br />
}  </p>
<p>Many thanks again.. god bless you my friend..</p>
<p>Ata..</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Matt</title>
		<link>http://sodeve.net/how-to-kill-ms-excel-process-started-by-aspnet/comment-page-1/#comment-1338</link>
		<dc:creator>Matt</dc:creator>
		<pubDate>Wed, 10 Sep 2008 12:57:32 +0000</pubDate>
		<guid isPermaLink="false">http://sodeve.net/how-to-kill-ms-excel-process-started-by-aspnet/#comment-1338</guid>
		<description>Process[] procs = Process.GetProcessesByName(&quot;EXCEL&quot;);
                                foreach (Process p in procs)
                                {
                                    p.Kill();
                                }</description>
		<content:encoded><![CDATA[<p>Process[] procs = Process.GetProcessesByName(&#8221;EXCEL&#8221;);<br />
                                foreach (Process p in procs)<br />
                                {<br />
                                    p.Kill();<br />
                                }</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Fred</title>
		<link>http://sodeve.net/how-to-kill-ms-excel-process-started-by-aspnet/comment-page-1/#comment-1130</link>
		<dc:creator>Fred</dc:creator>
		<pubDate>Thu, 13 Mar 2008 02:00:01 +0000</pubDate>
		<guid isPermaLink="false">http://sodeve.net/how-to-kill-ms-excel-process-started-by-aspnet/#comment-1130</guid>
		<description>I&#039;ve tried your code and I noticed that Excel applications that were opened AFTER my application started are also being closed. Any suggestions?

&lt;em&gt;&lt;strong&gt;Hardono&lt;/strong&gt;: Please check the trackback link in post no. 2&lt;/em&gt;</description>
		<content:encoded><![CDATA[<p>I&#8217;ve tried your code and I noticed that Excel applications that were opened AFTER my application started are also being closed. Any suggestions?</p>
<p><em><strong>Hardono</strong>: Please check the trackback link in post no. 2</em></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: SODEVE &#187; Blog Archive &#187; BUG FIX: How To Kill MS Excel Process Started by ASP.NET</title>
		<link>http://sodeve.net/how-to-kill-ms-excel-process-started-by-aspnet/comment-page-1/#comment-178</link>
		<dc:creator>SODEVE &#187; Blog Archive &#187; BUG FIX: How To Kill MS Excel Process Started by ASP.NET</dc:creator>
		<pubDate>Sun, 27 May 2007 16:34:35 +0000</pubDate>
		<guid isPermaLink="false">http://sodeve.net/how-to-kill-ms-excel-process-started-by-aspnet/#comment-178</guid>
		<description>[...] On 18th May 2007, Tanmoy commented on &#8220;How To Kill MS Excel Process Started by ASP.NET&#8221;. [...]</description>
		<content:encoded><![CDATA[<p>[...] On 18th May 2007, Tanmoy commented on &#8220;How To Kill MS Excel Process Started by ASP.NET&#8221;. [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Hardono Arifanto</title>
		<link>http://sodeve.net/how-to-kill-ms-excel-process-started-by-aspnet/comment-page-1/#comment-150</link>
		<dc:creator>Hardono Arifanto</dc:creator>
		<pubDate>Sat, 19 May 2007 09:17:37 +0000</pubDate>
		<guid isPermaLink="false">http://sodeve.net/how-to-kill-ms-excel-process-started-by-aspnet/#comment-150</guid>
		<description>It is interesting to note that the previous Excel version (we tested it on Office 2003) a new Excel.Exe process will be created everytime we open a document. 

But in Office 2007, only one Excel.Exe exists in the memory.  No matter how many documents you open.</description>
		<content:encoded><![CDATA[<p>It is interesting to note that the previous Excel version (we tested it on Office 2003) a new Excel.Exe process will be created everytime we open a document. </p>
<p>But in Office 2007, only one Excel.Exe exists in the memory.  No matter how many documents you open.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tanmoy</title>
		<link>http://sodeve.net/how-to-kill-ms-excel-process-started-by-aspnet/comment-page-1/#comment-141</link>
		<dc:creator>Tanmoy</dc:creator>
		<pubDate>Fri, 18 May 2007 08:38:12 +0000</pubDate>
		<guid isPermaLink="false">http://sodeve.net/how-to-kill-ms-excel-process-started-by-aspnet/#comment-141</guid>
		<description>Did u actually try to execute the above code when multiple instances (processes) of excel are running in task manager? p.MainModule.BaseAddress always returns the memory address of Excel.exe (not of the particular excel instance) and hence the above code kills all the excel processes running in the server.</description>
		<content:encoded><![CDATA[<p>Did u actually try to execute the above code when multiple instances (processes) of excel are running in task manager? p.MainModule.BaseAddress always returns the memory address of Excel.exe (not of the particular excel instance) and hence the above code kills all the excel processes running in the server.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
