[メモ] 25 November 2009

ExcelをVB.NETからcloseする方法

友人が困っていたので私も興味から調べてみました。
現象としてはVB.NETからExcelを開いて色々したあと閉じるとExcelのプロセスが残留するというものです。

下記のサイトがもっとも良いかも。
50 Ways to Kill Excel
http://www.devcity.net/PrintArticle.aspx?ArticleID=239

前置きにも
"How do I kill Excel" is a very common question asked in development forums and answered hundreds of times.
と書いてありますが、かなりポピュラーな問題のようです。
COMとか詳しくないのですが、外部リソースの終了処理の際にGCによる.NET側の開放とのタイミングの問題で上手にリソースが開放されてないために起きるようで、正規の手順を踏んでもダメな場合はもうこれはKillするしかないみたいですね。

で、大まかな流れとしては、ちゃんと開いて、ちゃんと閉じる。これを試して無理なら強制終了だ!そうです。
Excel Inception
 1. Open Excel
 2. The MAIN Sub
Excel Closure
 1. Ask Nicely
 2. COM Interface Management
 3. Garbage Collection and Memory Management
Excel Force-Kill
 Kill the Process

最後のForce-Killのところには、こんな一文もw
In most cases ... you need to kill a particular instance of Excel


DISALLOWED (TrackBack)

Comments

もりっち wrote:

僕もこれ昔やったことありますw
そんなことCloseの裏で勝手にやってくれればいいのに、、と思った記憶が。

15 February 2010 at 20:26
Term Paper wrote:

This is such a great news, it really like this, Your blog is nice and informative. Thanks for the article.

04 March 2010 at 19:53

Add Comment

:

:
: