Results 1 to 4 of 4
  1. #1
    snipe's Avatar
    snipe is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Sep 2013
    Posts
    287

    Import all excel docs in a folder into access with VBA?

    Hey guys,

    I have about 60 (or more depending on how long it takes me to do this) excel files that I need to import into access. They do follow a naming format (YYYY_MM_DD.xls).



    What is the best way to do a mass import and get all of these into access?

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Code can loop through folder files and import everything with .xls extension.

    Code to list files http://www.devhut.net/2012/07/13/vba...-or-directory/

    Include code to check for the file extension as well. The import code might just be TransferSpreadsheet method.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    when you get the code to loop thru files...
    (pseudo code)
    for each fil in files
    'remove existing xl file attached
    DeleteTbl kTBL
    'attach next file
    DoCmd.TransferSpreadsheet acLink, acSpreadsheetTypeExcel9, kTBLx, txtFullPath, True
    'import
    docmd.openquery "qsImportXL"
    next

  4. #4
    snipe's Avatar
    snipe is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Sep 2013
    Posts
    287
    Thanks guys. Transferspreadsheet added to the code that June7 linked worked great! All good!

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 10
    Last Post: 06-16-2014, 08:37 AM
  2. Replies: 3
    Last Post: 03-06-2014, 03:53 PM
  3. Import access query data into excel file, using excel vba
    By exceljockey in forum Import/Export Data
    Replies: 3
    Last Post: 11-15-2013, 02:36 PM
  4. Replies: 4
    Last Post: 12-17-2012, 01:21 PM
  5. Import Word Docs as Form Template
    By Spectre50 in forum Forms
    Replies: 0
    Last Post: 03-05-2012, 01:51 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums