inna Level: Guest

|
VB and Excel
Can somebody help
I have wrote the code for reading Excel.
It's load array with value from Excel.
But not all data can load. It's give the error
"Invalid use of null"
for example:
1234
2345
M234 - this record will have the error
3456
Thanks a lot
if you put checking for null
it's will skip the record "M234"
but it's there.
Because if you open Excel not lilke object
than it's will work. But it's work very long time, if you have more than 60000record it's will run for whole day.
HELP HELP
code below
Dim sheetname1, FilePath1 As String
Dim cn1 As Object
Dim rs1 As Object
Dim sConn1 As String
'On Error GoTo EH
DoEvents
FilePath1 = "C:Mikecc_labor_updN.xls"
sheetname1 = "Sheet1"
sConn1 = "DRIVER=Microsoft Excel Driver (*.xls);" & "DBQ=" & FilePath1
Set cn1 = CreateObject("ADODB.Connection")
Set rs1 = CreateObject("ADODB.Recordset")
cn1.ConnectionString = sConn1
cn1.Open
rs1.Source = "SELECT * FROM [" & sheetname1 & "$]" '& sql
rs1.Open , cn1, , adCmdText
Dim ws As Object
numarr = 0
'rs.MoveFirst
rs1.MoveFirst
Do Until rs1.EOF
numarr = numarr + 1
ReDim Preserve arrJob(numarr)
If not IsNull(rs1.Fields(0).Value) Then
arrJob(numarr).ijobNum = rs1.Fields(0).Value
End if
Debug.Print rs1.Fields(0)
rs1.MoveNext
Loop
rs1.Close
cn1.Close
[Edited by inna on 13-12-2002 at 04:05 PM GMT]
|