0

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.

Edited by Nick Evan: Add code-tags; Converted snippet to thread

3
Contributors
3
Replies
6
Views
7 Years
Discussion Span
Last Post by Nick Evan
0

Try and re-post your problem as a NEW thread, you posted as a code snippet. I will then send you help.

0

Try and re-post your problem as a NEW thread, you posted as a code snippet. I will then send you help.

When you see posts like this in the future, just click the "flag bad post" link. This will send a notification to the moderating team and a moderator can change the snippet to a forum-thread.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.