タイトル : すいません。またタスクエラーです(^^;) 投稿日 : 2004/09/06(Mon) 15:33 投稿者 : クーガ
[OSのVer]:Windows XP [VBのVer]:VB.NET 2003 フォーマットは直ったのですが、 先ほどまでは、タスクにエクセルが残らなかったのですが、 また動かしてみると、タスクにエラーが残るようになりました。 前のと同じコードなのですが、なぜこんな現象がおきるのかがわかりません。 すいません。ご教授ください Dim FileSaveName As String ''ファイル名取得 Dim dlg_FileSave As DialogResult Dim preCursor As Cursor = Cursor.Current Dim sr As IO.StreamWriter Dim linetext As String 'ファイルに格納 ''エクセルインスタンス格納 Dim xlApp As Excel.Application = Nothing ''エクセルブック格納 Dim xlBook As Excel.Workbook = Nothing ''エクセルシート格納 Dim xlSheet As Excel.Worksheet = Nothing Dim xlCell As Object xlApp = CreateObject("Excel.Application") '空白の新しいブックを追加 xlBook = xlApp.Workbooks.Add '新しいシートを追加 xlSheet = xlBook.Worksheets(1) xlSheet.Name = "売上指示" xlCell = xlSheet.Cell 'ファイル名を指定して保存 SaveFileDialog1.Filter = "Excel(*.xls)|*.xls" dlg_FileSave = SaveFileDialog1.ShowDialog SaveFileDialog1.RestoreDirectory = False If dlg_FileSave = DialogResult.Cancel Then Exit Sub End If FileSaveName = SaveFileDialog1.FileName sr = New IO.StreamWriter(FileSaveName, False, System.Text.Encoding.GetEncoding("Shift- JIS")) ' 表示項目 xlsheet(1,1) = "aaa" ' Excelを終了 xlBook.Close(False) If Not xlSheet Is Nothing Then System.Runtime.InteropServices.Marshal.ReleaseComObject(xlSheet) xlSheet = Nothing End If 'xlSheet = Nothing 'GC.Collect() If Not xlBook Is Nothing Then System.Runtime.InteropServices.Marshal.ReleaseComObject(xlBook) xlBook = Nothing End If 'xlBook = Nothing 'GC.Collect() If Not xlApp Is Nothing Then System.Runtime.InteropServices.Marshal.ReleaseComObject(xlApp) xlApp = Nothing End If 'GC.Collect() 'xlApp = Nothing GC.Collect() sr.Close() ' カーソルを元に戻す Cursor.Current = preCursor |