can anyone help me with the code.
am trying to import the content of an excel sheet to my access database using common dialog in vb6. i tried this code below but is not working ........

Private Sub sLoadExcel()
If CommonDialog1.FileName = "" Then Exit Sub
Dim exc As Object
Set exc = CreateObject("Excel.Application")
exc.Workbooks.Add (CommonDialog1.FileName)
exc.Visible = True

'Dim i As Integer
For i = 0 To exc.Row - 1
With rstAS400
.AddNew
.Fields![STUDID] = exc.cells(i, 1)
.Fields![FNAME] = exc.cells(i, 2)
.Fields![LNAMSE] = exc.cells(i, 3)
.Fields![SEX] = exc.cells(i, 4)
.Fields![LDOB] = exc.cells(i, 5)
.Update
Next i
End With
End Sub

please help me out.

The attached will solve your problem. Remember to reference excell in your project, otherwise it will still not work.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.