thechazm
VBA, VB.net, C#, Java
- Local time
- Today, 18:59
- Joined
- Mar 7, 2011
- Messages
- 515
Add the following red lines to your function in the module at the exact spot I have shown here and it should resolve the issue. But if you keep getting error messages to get to that point then that needs figured out as well.
Code:
Function GetDataFromExcelSheets(lSheetNumber As Long)
Dim xlsApp As Excel.Application, xlsWorkBook As Excel.Workbook, xlsSheet As Excel.Worksheet
Dim db As Database, rs As DAO.Recordset
ReDim Arr(1 To 100)
'On Error GoTo ErrHandler
Set db = CurrentDb
Set rs = db.OpenRecordset("Select * from [IDMSummary]", dbOpenDynaset)
BrowseFile "CSV"
Set xlsApp = New Excel.Application
For x = LBound(Arr) To UBound(Arr)
If CStr(Arr(x)) = "" Then Exit For
Set xlsWorkBook = xlsApp.Workbooks.Open(CStr(Arr(x)))
Set xlsSheet = xlsApp.Worksheets(lSheetNumber)
For i = 2 To xlsSheet.Cells(xlsSheet.Rows.Count, "A").End(xlUp).Row Step 2 ' Starts at row 3 in excel sheet and gets a total row count on column O. &
'If your longest column is different then change the letter to that column. Also if your data starts on a different row make sure to change the 3 to whatever number it needs to be.
' Do operations here on the excel sheets
'Debug.Print xlsSheet.Cells(i, 15) ' Prints out column 15 data in the immediate window
With rs
.AddNew
![SpreadsheetName] = xlsSheet.Name
![Total Number of checks inserted into device] = xlsSheet.Cells(i, 3)
![Checks moved to escrow] = xlsSheet.Cells(i, 4)
![Checks accepted by host] = xlsSheet.Cells(i, 5)
![Checks rejected by non-hardware logic] = xlsSheet.Cells(i, 6)
![Checks rejected by hardware] = xlsSheet.Cells(i, 7)
![Number of Checks Rejected by Image Too Light] = xlsSheet.Cells(i, 8)
![Number of Checks Rejected by Image Too Dark] = xlsSheet.Cells(i, 9)
![Number of Checks Rejected by Excessive Skew] = xlsSheet.Cells(i, 10)
![Number of Checks Rejected by Out Of Focus] = xlsSheet.Cells(i, 11)
![Number of Checks Rejected by Payee Endorsement Presence] = xlsSheet.Cells(i, 12)
![Number of Checks Rejected by Piggyback] = xlsSheet.Cells(i, 13)
![Number of Checks Rejected by Signature Presence] = xlsSheet.Cells(i, 14)
![Number of Checks Rejected without magnetics] = xlsSheet.Cells(i, 15)
![Number of Deposit Slip Rejects] = xlsSheet.Cells(i, 16)
![Number of Travelers Check Rejects] = xlsSheet.Cells(i, 17)
![Number of IRD Rejects] = xlsSheet.Cells(i, 18)
![Number of Saving Bond Rejects] = xlsSheet.Cells(i, 19)
![Manual amount entry required] = xlsSheet.Cells(i, 20)
![Hardware Document Return Reason Too Short (1)] = xlsSheet.Cells(i, 21)
![Hardware Document Return Reason Too Long (2)] = xlsSheet.Cells(i, 22)
![Hardware Document Return Reason Too Narrow (3)] = xlsSheet.Cells(i, 23)
![Hardware Document Return Reason Multiples (4)] = xlsSheet.Cells(i, 24)
![Hardware Document Return Reason Can't Align (5)] = xlsSheet.Cells(i, 25)
![Hardware Document Return Reason Can't Move to Align (6)] = xlsSheet.Cells(i, 26)
![Hardware Document Return Reason Shutter Failed to Close (7)] = xlsSheet.Cells(i, 27)
![Hardware Document Return Reason Can't Move to Escrow (8)] = xlsSheet.Cells(i, 28)
![Hardware Document Return Reason Height Rejection (9)] = xlsSheet.Cells(i, 29)
![Hardware Document Return Reason Document too wide (10)] = xlsSheet.Cells(i, 30)
![Hardware Document Return Reason UDD Learning Document (11)] = xlsSheet.Cells(i, 31)
![Hardware Document Return Reason UDD Learning Failure (12)] = xlsSheet.Cells(i, 32)
![Hardware Document Return Reason UDD Learning Done (13)] = xlsSheet.Cells(i, 33)
![Hardware Document Return Reason Last in first out reject (14)] = xlsSheet.Cells(i, 34)
![Hardware Document Return Reason Processing failure (15)] = xlsSheet.Cells(i, 35)
![Hardware Document Return Reason Unknown Reason (100)] = xlsSheet.Cells(i, 36)
![Hardware Media Return Reason Too Short (1)] = xlsSheet.Cells(i, 37)
![Hardware Media Return Reason Too Long (2)] = xlsSheet.Cells(i, 38)
![Hardware Media Return Reason Can't Strip (3)] = xlsSheet.Cells(i, 39)
![Hardware Media Return Reason Can't Pick (4)] = xlsSheet.Cells(i, 40)
![Hardware Media Return Reason Max Documents on Escrow (5)] = xlsSheet.Cells(i, 41)
![Hardware Media Return Reason Irregular Media (6)] = xlsSheet.Cells(i, 42)
![Hardware Media Return Reason Document Stopped (7)] = xlsSheet.Cells(i, 43)
![Hardware Media Return Reason Can't Move to Pick (8)] = xlsSheet.Cells(i, 44)
![Hardware Media Return Reason Can't Clamp Documents (9)] = xlsSheet.Cells(i, 45)
![Hardware Media Return Reason Can't Close Shutter (10)] = xlsSheet.Cells(i, 46)
![Hardware Media Return Reason Processing Error (11)] = xlsSheet.Cells(i, 47)
![Hardware Media Return Reason Document too Narrow (12)] = xlsSheet.Cells(i, 48)
![Hardware Media Return Reason Failed to Align Transport (13)] = xlsSheet.Cells(i, 49)
![Hardware Media Return Reason Unknown Reason (100)] = xlsSheet.Cells(i, 50)
![Total number of Store Transactions that were started] = xlsSheet.Cells(i, 51)
![Total number of DA Transactions stored in DB] = xlsSheet.Cells(i, 52)
![Total number of Cash and Check Items stored in DB] = xlsSheet.Cells(i, 53)
![Total number of DA Transactions that failed to be stored in DB] = xlsSheet.Cells(i, 54)
![Total number of Cash and Check Items that failed to be stored in] = xlsSheet.Cells(i, 55)
' Fill in the rest of the field information here
.Update
End With
Next i
Next x
[COLOR=red]rs.close[/COLOR]
[COLOR=red]set rs = nothing[/COLOR]
[COLOR=red]set db = nothing[/COLOR]
xlsApp.Quit
Set xlsSheet = Nothing
Set xlsWorkSheet = Nothing
Set xlsApp = Nothing
Exit Function
ErrHandler:
MsgBox Err.Number & " - " & Err.Description
[COLOR=red]rs.close[/COLOR]
[COLOR=red]set rs = nothing[/COLOR]
[COLOR=red]set db = nothing[/COLOR]
[COLOR=red][/COLOR]
[COLOR=red]xlsApp.Quit[/COLOR]
Set xlsSheet = Nothing
Set xlsWorkSheet = Nothing
Set xlsApp = Nothing
End Function