Ask a Question related to Microsoft Access, Design and Development.

  1. #1

    Default import excel

    hi,
    Have several excel files in a folder. want to import them all at once
    (ofcource if it can automatically)

    they all have 2 sheets (open and Closed)
    they all have at line 6 the header (both sheets)
    they all have data started at line 7 (both sheets)

    how can I import these excel files into access?
    Kisoen


    R.Kisoenpersad Guest

  2. Similar Questions and Discussions

    1. How can I import an excel spreadsheet into SQL?
      I'm having a hard time finding info on how to do this. Does anyone have any examples, without purchasing a custom tag, on how to do this?
    2. import from excel
      Goal: How to import data from an excel file to an oracle or access db. Help needed. tc
    3. Exporting and Import Excel
      OK, So on my website, I want to allow the user to download an Excel Spreadsheet and update it, then reupload it. For download, I have it...
    4. Need to Import Excel Graphs - ID2
      I've found info on how to import spread sheets, BUT I need to import charts/graphs created in Excel. What is the best way to accomplish this? I don't...
    5. Need to import data to excel
      Is there a way to import the data in xml file to excel spreadsheet as well as provide required formatting on the data. I have excel 2000. Thanks...
  3. #2

    Default import excel

    Kisoen,
    Below is a sample set of code which opens an excel file in
    OfficXP, reads lines, puts data in an access table, then
    closes the spreadsheet. To use it for your purposes you
    could put some of the code in a loop which opens the table
    recordset first, then loops through each spreadsheed
    opening them and reading the data into the table, the
    close everything and get out. I hope it helps.
    Tom

    Dim rst As Recordset
    Dim intLineCounter As Integer
    Dim intBlankCounter As Integer
    Dim oApp As Excel.Application
    Dim strCheck As String
    Dim strSQL As String
    ' ctl_ImportFileName has the Excel spreadsheet file name
    strCheck = Dir$(ctl_ImportFileName)
    If strCheck = "" Then
    MsgBox "Can't find file '" & ctl_ImportFileName _
    & ".' Please check location of the file you wish " _
    & "to import, and try again."
    GoTo Exit_btn_CallsImport_Click
    End If

    ' The following sets up the records set which will be
    ' added to.

    strSQL = "Select * From tblCalls " _
    & "Where callDate = #" & ctl_CallDate & "#"
    DoCmd.SetWarnings False
    DoCmd.Hourglass True

    Set rst = CurrentDb.OpenRecordset(strSQL)
    Set oApp = New Excel.Application
    oApp.Workbooks.Open FileName:=ctl_ImportFileName
    oApp.Visible = True
    intLineCounter = 1
    intBlankCounter = 0
    Do Until intBlankCounter = 4
    intLineCounter = intLineCounter + 1
    oApp.Cells(intLineCounter, 1).Select
    If oApp.Selection = "" Then
    intBlankCounter = intBlankCounter + 1
    GoTo NextLoop
    End If
    ' The blank counter allows me to loop till I have found
    ' 3 blank lines in a row. You can change this logic
    ' to be from line to line, whatever works for you.
    intBlankCounter = 0
    If Not IsDate(oApp.Selection) Then GoTo NextLoop
    rst.AddNew
    rst!callDate = oApp.Cells(intLineCounter, 1)
    rst!callTime = oApp.Cells(intLineCounter, 2)
    rst!callState = oApp.Cells(intLineCounter, 3)
    rst!callStation = oApp.Cells(intLineCounter, 5)
    rst!callLogDate = ctl_LogDate
    rst!callException = 0
    rst.Update
    NextLoop:
    Loop

    oApp.Quit
    Set oApp = Nothing
    rst.Close
    Set rst = Nothing

    Exit_btn_CallsImport_Click:
    DoCmd.SetWarnings True
    DoCmd.Hourglass False
    Exit Sub

    Err_btn_CallsImport_Click:
    MsgBox Err.Number & "-" & Err.Description, vbCritical
    Resume Exit_btn_CallsImport_Click
    >-----Original Message-----
    >hi,
    >Have several excel files in a folder. want to import them
    all at once
    >(ofcource if it can automatically)
    >
    >they all have 2 sheets (open and Closed)
    >they all have at line 6 the header (both sheets)
    >they all have data started at line 7 (both sheets)
    >
    >how can I import these excel files into access?
    >Kisoen
    >
    >
    >.
    >
    Tom Youngquist Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139