tagCANDY CGI VBレスキュー(花ちゃん) の Visual Basic 2010 用 掲示板(VB.NET 掲示板)
VBレスキュー(花ちゃん) の Visual Basic 2010 用 掲示板(VB.NET 掲示板)
[ツリー表示へ]  [ワード検索]  [Home]

タイトル Excelのタスクが終了しない
投稿日: 2004/09/06(Mon) 13:02
投稿者クーガ
[OSのVer]:Windows XP   [VBのVer]:VB.NET   2003

エクセルを終了しても、タスクが終了しません。
フォーマットを設定すると、タスクが終了してくれません
フォーマットを設定すると、タスクは終了してくれないのでしょうか?
それとも、Cellが何か悪さをしているのでしょうか?
原因がわかりません。教えてください

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

xlApp = CreateObject("Excel.Application")

'空白の新しいブックを追加
xlBook = xlApp.Workbooks.Add
'新しいシートを追加
xlSheet = xlBook.Worksheets(1)
xlSheet.Name = "売上指示"
      
'ファイル名を指定して保存

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.Cells(1, 1).NumberFormatLocal = "@"
        
' 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

- 関連一覧ツリー をクリックするとツリー全体を一括表示します)

古いスレッドにレスはつけられません。