掲示板システム
ホーム
アクセス解析
カテゴリ
ログアウト
Excel操作時のオブジェクト参照エラーについて・・・ (ID:116896)
名前
ホームページ(ブログ、Twitterなど)のURL (省略可)
本文
VB.NETでExcelを操作しているのですが、下記コード①で 「オブジェクト参照がオブジェクト インスタンスに設定されていません。」というエラーがでてしまいます。 Excelの操作方法などは間違っていないと思うのですが・・・・ おねがいします。 コード 'エクセル起動 Dim oExcel As Excel.Application Dim oBook As Excel.Workbook Dim oBooks As Excel.Workbooks Dim oSheet As Excel.Worksheet oExcel = CreateObject("Excel.Application") oBooks = oExcel.Workbooks oBook = oBooks.Open(FilePach)・・・・・①ここでエラーが出ます。 oExcel.Visible = False oExcel.UserControl = False oSheet = oBook.Worksheets(Trim(lotNo)) 処理・・・・・ 'エクセルの終了 oExcel.Quit() 'プロセスの開放 If Not oSheet Is Nothing Then System.Runtime.InteropServices.Marshal.ReleaseComObject(oSheet) oSheet = Nothing End If If Not oBook Is Nothing Then System.Runtime.InteropServices.Marshal.ReleaseComObject(oBook) oBook = Nothing End If If Not oBooks Is Nothing Then System.Runtime.InteropServices.Marshal.ReleaseComObject(oBooks) oBooks = Nothing End If If Not oExcel Is Nothing Then System.Runtime.InteropServices.Marshal.ReleaseComObject(oExcel) oExcel = Nothing End If GC.Collect()
←解決時は質問者本人がここをチェックしてください。
戻る
掲示板システム
Copyright 2020 Takeshi Okamoto All Rights Reserved.