Newby question: import Excel worksheet 
Author Message
 Newby question: import Excel worksheet

Hello,

I have built an application in vb6 that connects to sql server. Now I want
to build an import function, data on a simple Excel worksheet must be
imported in an existing table. How can I do it? Do I make a connection, or
just read all the records one by one??

Any help will be highly appreciated

Thanks,

Joost



Thu, 25 Dec 2003 18:35:30 GMT  
 Newby question: import Excel worksheet
Private Sub cmdLoad_Click()

    On Error GoTo EH:

    blnExlAppSet = False
    cmdLoad.Enabled = False
    cmdExit.Enabled = False

    With dlgInput
        .CancelError = True
        .MaxFileSize = 2048
        .Filter = "Microsoft Excel Workbook(*.xls)|*.xls"
        .FileName = ""
        .ShowOpen
        strInputLocation = .FileName
    End With

    Screen.MousePointer = vbHourglass
    txtBatchMsg.ForeColor = vbYellow
    txtBatchMsg.Text = "Working, please wait..."
    Set exlApp = Nothing
    DoEvents
    Set exlApp = CreateObject("Excel.Application")
    blnExlAppSet = True
    DoEvents
    exlApp.Workbooks.Open FileName:=strInputLocation
    DoEvents

    txtBatchMsg.ForeColor = vbGreen
    txtBatchMsg.Text = strInputLocation & vbCrLf & _
                       "has been succesfully loaded." & vbCrLf & vbCrLf & _
                       "Please click the 'Verify' button to proceed," &
vbCrLf & _
                       "or click the 'Cancel' button" & vbCrLf & _
                       "to cancel the operation. "

    bytState = NowLoaded
    Call commandButtons(bytState)
    Screen.MousePointer = vbDefault
    Exit Sub

EH:

    If blnExlAppSet = True Then
        exlApp.Quit
        blnExlAppSet = False
    End If
    Set exlApp = Nothing
    bytState = nowIdle
    Call commandButtons(bytState)
    Screen.MousePointer = vbDefault
    If Err.Number = 32755 Then
        txtBatchMsg.ForeColor = vbYellow
        txtBatchMsg.Text = "No spreadsheet was selected." & vbCrLf & vbCrLf
& _
                           "Please select a year, then click the 'Load'
button to load a spreadsheet."
        DoEvents
    Else
        txtBatchMsg.ForeColor = vbRed
        txtBatchMsg.Text = "A processing error has occurred, please try
again."
        DoEvents
        MsgBox "Error Number: " & Err.Number & vbCrLf & Err.Description,
vbCritical + vbOKOnly, conTableName
    End If

End Sub


Quote:
> Hello,

> I have built an application in vb6 that connects to sql server. Now I want
> to build an import function, data on a simple Excel worksheet must be
> imported in an existing table. How can I do it? Do I make a connection, or
> just read all the records one by one??

> Any help will be highly appreciated

> Thanks,

> Joost



Thu, 15 Jan 2004 10:38:50 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Newby question: import Excel worksheet

2. Import Excel Worksheet(2)

3. Import multiple excel files with inconsistent number of worksheets in each into ACCESS

4. Importing an Excel Worksheet

5. Import Excel worksheets via VB and DAO?

6. VB 4.0 Importing Data from Excel Worksheet into Access 2.0

7. Import Excel Worksheet into an Access Database

8. Excel worksheet questions

9. question about reading in excel worksheet data

10. Excel worksheet question

11. Excel Worksheets...Newbie Question

12. OLE: Excel worksheet without using Excel

 

 
Powered by phpBB® Forum Software