- PR -

Excelのプロセス終了方法は??

投稿者投稿内容
MyTime
常連さん
会議室デビュー日: 2003/01/29
投稿数: 40
お住まい・勤務地: 静岡県
投稿日時: 2003-08-18 21:59
次のように入れ替えるだけでも、効果がありそうに思えるのは、安易でしょうか?

xlSheet.SaveAs("C:\\aaa.xls")
xlBook.Close()
xlApp.Quit()
xlSheet = Nothing
xlBook = Nothing
xlApp = Nothing

xlSheet.SaveAs("C:\\aaa.xls")
xlSheet = Nothing
xlBook.Close()
xlBook = Nothing
xlApp.Quit()
xlApp = Nothing

takahon
会議室デビュー日: 2003/08/15
投稿数: 4
投稿日時: 2003-08-19 10:32
たくさんの返信有り難うございます。
過去レス及び皆様の意見を参考にし、無事プロセスが終了しました。

Sub TestExcel()
Dim xlApp As New Excel.Application
Dim xlBooks As Excel.Workbooks = xlApp.Workbooks
Dim xlBook As Excel.Workbook = xlBooks.Open("c:\aaa.xls")

xlApp.DisplayAlerts = False
Dim xlSheets As Excel.Sheets = xlBook.Worksheets
Dim xlSheet As Excel.Worksheet = CType(xlSheets(1), Excel.Worksheet)
Dim xlRange As Excel.Range = xlSheet.Cells
xlRange(2, 2) = "This is column B row 2"
xlBook.Save()
xlBook.Close(False)
xlApp.DisplayAlerts = True

xlApp.Quit()
System.Runtime.InteropServices.Marshal.ReleaseComObject(xlRange)
System.Runtime.InteropServices.Marshal.ReleaseComObject(xlSheet)
System.Runtime.InteropServices.Marshal.ReleaseComObject(xlSheets)
System.Runtime.InteropServices.Marshal.ReleaseComObject(xlBook)
System.Runtime.InteropServices.Marshal.ReleaseComObject(xlBooks)
System.Runtime.InteropServices.Marshal.ReleaseComObject(xlApp)
End Sub

MMX
ぬし
会議室デビュー日: 2001/10/26
投稿数: 861
投稿日時: 2003-09-30 09:49
[PRB] Visual Studio .NET クライアントで自動化した Office アプリケーションが終了しない
http://support.microsoft.com/default.aspx?scid=kb;ja;317109

スキルアップ/キャリアアップ(JOB@IT)