Hi guys
I need export data of access to excel pre-formated file, the final report have a partnumber and my excel's dataset have the same partnumber too. I need your help because i have a error "An unhandled exception of type 'System.NullReferenceException' ocurred in RECON_REPORT.exe
Aditional Information:Object Reference not set to an instance of an object."
I glad the help.
It is my code:
Dim exopen As OpenFileDialog
Dim exapp As Excel.Application
Dim exbook As Excel.Workbook
Dim exsheet As Excel.Worksheet
Dim exfile As String
exapp = New Excel.Application
exopen = New OpenFileDialog
exopen.Filter = "Open Microsoft Excel Document (HPDRIVESRECONXXXX.xls)|*.xls"
exopen.Title = "Open Final Report HPDRIVESRECON"
If exopen.ShowDialog = DialogResult.OK Then
exfile = exopen.FileName
End If
exbook = exapp.Workbooks.Open(exfile)
exapp.Visible = False
exbook.Activate()
With exbook
exsheet = .Worksheets("May2006")
info = 1
Dim cols As Int32 = 7
For Each ds2row In ds2excel.Tables("RECON_REPORT").Rows
For info = 0 To ds2excel.Tables &_("RECON_REPORT").Rows.Count - 1
'here is my error
If ds2excel.Tables("MASTERS").Rows(info).Item 0).ToString =&_ exsheet.Range("B" & cols.ToString).Value Then
exsheet.Cells(cols, "S") = ds2row.Item &_ ("ERWC_IW")
exsheet.Range("S" & info.ToString).Value =&_ ds2row("ERWC_IW")
Exit For
End If
Next info
cols = cols + 1
Next
End With
exbook.Save()
exapp.Visible = True