Okay I am trying to make a class library that takes information from an excel file and puts it into an access database, but I keep getting this dumb object reference error that always screws me over. Here is my code:
vb Code:
Dim xlApp As Excel.Application Dim xlWbs As Excel.Workbooks Dim xlBook As Excel.Workbook Dim xlSheet As Excel.Worksheet Dim xlRange As Excel.Range Dim strExcelPath As New String("C:\Users\Aj\Desktop\Tax_Research_Template_2010_-_Excel.xls") Dim accConn As String = "C:\Users\Aj\Desktop\TaxCert_be.accdb" Dim xlDT As New DataTable Dim xlDR As DataRow = xlDT.NewRow Public Sub XLMain() xlBook = xlWbs.Open(strExcelPath) xlSheet = xlBook.Worksheets(1) ReadXL() ImportXL() CloseExcel() End SubCode:Object reference not set to an instance of an object. xlBook = xlWbs.Open(strExcelPath)




Reply With Quote