Results 1 to 6 of 6
  1. #1
    Join Date
    Nov 2003
    Posts
    2

    Unanswered: batch importing of .csv files

    i have about a thousand csv files that i'm trying to merge into a single database. without importing each one, one at a time, is it possible to import every file of a directory at once.

    thanks in advance.

  2. #2
    Join Date
    Nov 2003
    Posts
    1,487
    read up on this function:

    DoCmd.TransferDatabase acImport

    It may help you.

  3. #3
    Join Date
    Oct 2003
    Location
    Ger
    Posts
    1,969
    Provided Answers: 1

    Re: batch importing of .csv files

    Originally posted by ncsu_dc
    i have about a thousand csv files that i'm trying to merge into a single database. without importing each one, one at a time, is it possible to import every file of a directory at once.

    thanks in advance.
    You can put their names in an array and make a loop something like that

    Dim arr_FilesNames
    dim cPath as string , k as long
    cPath="C:\yourDir\"
    For k = 1 to UBound(arr_FilesNames)
       DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel97, arr_FilesNames(k), ctPath & arr_FilesNames(k), True
    next

  4. #4
    Join Date
    Oct 2003
    Location
    Ger
    Posts
    1,969
    Provided Answers: 1

    Re: batch importing of .csv files

    Originally posted by ncsu_dc
    i have about a thousand csv files that i'm trying to merge into a single database. without importing each one, one at a time, is it possible to import every file of a directory at once.

    thanks in advance.
    Incase of .txt files or .csv

    You can put their names in an array and make a loop something like that

    Dim arr_FilesNames
    dim cPath as string , k as long
    cPath="C:\yourDir\"
    For k = 1 to UBound(arr_FilesNames)
      DoCmd.TransferText acImportDelim, , arr_FilesNames(k), cPath & arr_FilesNames(k), True
    next

  5. #5
    Join Date
    Nov 2003
    Posts
    2
    they are csv files, but i get a type mismatch at arr_FileNames(k)....

  6. #6
    Join Date
    Oct 2003
    Location
    Ger
    Posts
    1,969
    Provided Answers: 1

    Lightbulb

    Originally posted by ncsu_dc
    they are csv files, but i get a type mismatch at arr_FileNames(k)....
    Did you fill the arry with the files names like that:
    arr_FileNames(1)="csv01.csv"
    arr_FileNames(2)="csv02.csv"
    and so on.

Posting Permissions

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