- - PR -
すいません。。EXCELプロセスについてです。
1
投稿者 | 投稿内容 | ||||
---|---|---|---|---|---|
|
投稿日時: 2006-07-28 16:33
EXCELプロセスがどうしても消えません。
EXEが終了すると同時に消えるのですが、開放した時点で消えません。 過去のEXCELプロセスについてのスレをよませていただいたのですが、該当するものがなかったので、投稿させていただきました。 クエリテーブルの実行部分をコメント化するとプロセスは残りませんでしたので、クエリを使用するにあたり、なにか足りない箇所があるように思えます。 宜しくお願い致します。 -----------------ソース----------------------------------- Dim xlsApp As Excel.Application Dim xlsFormatBook As Excel.Workbook Dim xlsFormatBooks As Excel.Workbooks Dim xlsFormatSheets As Excel.Sheets Dim xlsFormatSheet As Excel.Worksheet Dim xlRange As Excel.Range Dim xlsQuery As Excel.QueryTables xlsFormatBook = xlsFormatBooks.Add(ファイル名1) xlsFormatSheets = xlsFormatBook.Worksheets xlsFormatSheet = xlsFormatSheets("Sheet1") 'xlsFormatSheet.Activate() xlRange = xlsFormatSheet.Range("a1") xlsQuery = xlsFormatSheet.QueryTables With xlsQuery.Add(Connection:= _ "TEXT;" & ファイル名2 _ , Destination:=xlRange.Range("A1")) .Name = "Sheet1" .Refresh(BackgroundQuery:=False) End With xlsApp.DisplayAlerts = False xlsFormatBook.SaveAs(ファイル名) xlsApp.DisplayAlerts = True If Not xlRange Is Nothing Then System.Runtime.InteropServices.Marshal.ReleaseComObject(xlRange) End If If Not xlsFormatSheet Is Nothing Then System.Runtime.InteropServices.Marshal.ReleaseComObject(xlsFormatSheet) End If If Not xlsFormatSheet Is Nothing Then System.Runtime.InteropServices.Marshal.ReleaseComObject (xlsFormatSheets) End If If Not xlsFormatBook Is Nothing Then xlsFormatBook.Close(SaveChanges:=False) System.Runtime.InteropServices.Marshal.ReleaseComObject(xlsFormatBook) End If If Not xlsFormatBooks Is Nothing Then System.Runtime.InteropServices.Marshal.ReleaseComObject(xlsFormatBooks) End If If Not xlsApp Is Nothing Then xlsApp.Quit() System.Runtime.InteropServices.Marshal.ReleaseComObject(xlsApp) End If | ||||
|
投稿日時: 2006-07-28 16:36
おそらくここが原因 (複数) だと思われます。 COM ラッパの参照がどうなっているのかイメージして、見直してみてください。 _________________ C# と VB.NET の入門サイト じゃんぬねっと日誌 | ||||
|
投稿日時: 2006-07-28 17:09
この処理中にエラーが発生したら、どうなるんでしょうか・・・
面倒でも、Try 〜 Finally をつけましょう。 COM オブジェクトを解放する |
1