Results 1 to 3 of 3
  1. #1
    sauce1979 is offline Novice
    Windows XP Access 2003
    Join Date
    Oct 2011
    Posts
    2

    Import Data from Excel into Access

    I am tryng to create an access application that browses a folder for excel files with a certian naming convention and imports the first worksheet into an access tables. I am a sql server developer but have very little experience programming in Access. I would imagine this needs to be built with VBA.



    Each valid excel sheet represents a buisness unit. The data in each excel spreadsheet is of the same format. There are 12 Business units altogether thus 12 files should be in the driectroy at a given time.

    As the files are imported there should be some data validation to ensure that the data is correct. If the data is incorrect it will not be loaded into the database.

    Files that are processed should be moved to a different folder. Failed files should remain in the original directory.
    I would like to have a way of processing all files at once or an individual file. Therefore I would need some brwosing functionality.

    Finally I would like to have some log info which will show what was processed and what was not processed. Maybe some sort of import report.

    Any information or ideas would be very much appreciated.

  2. #2
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    There are a bunch of things you're asking for here.

    First, if your files are all in the same folder and always will be it's pretty simple to set up a program to browse the files that follow a certain naming convention.

    look at filesystemobject commands to do this. Here's a reference:

    http://www.4guysfromrolla.com/webtech/090599-1.shtml

    Next you want a method to open an excel file and read specific cells:

    http://www.justkez.com/vbscript-and-excel/

    There are other ways to get specific cells like this

    Code:
    Dim xlApp 
    Dim xlBook 
    Dim xlSheet 
    Set xlApp = CreateObject("Excel.Application") 
    xlApp.visible = true 
    Set xlBook = xlApp.Workbooks.open("FilePathandName") 
    Set xlSheet = xlBook.Worksheets("SheetName") 
    MsgBox  xlSheet.Cells(1, 1).Value
    Once you retrieve the values and do your error checking you can use the filesystemobject to also move the file to a new location or leave it where it is.

    Code:
    FileSystemObject.CopyFile "filepathandfolder", "newfolder"
    As you read each file names using the filesystemobject you can add the file to a log table and, if it passes your validation, update the processed flag, leaving it blank if it fails.

  3. #3
    sauce1979 is offline Novice
    Windows XP Access 2003
    Join Date
    Oct 2011
    Posts
    2
    thanks for the info. will give it a go and let you know how it goes

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

Similar Threads

  1. Import data from Excel
    By jhawkins49 in forum Import/Export Data
    Replies: 5
    Last Post: 08-23-2011, 02:05 PM
  2. Import data from Excel
    By mari_hitz in forum Import/Export Data
    Replies: 1
    Last Post: 06-13-2011, 07:34 AM
  3. Import to Excel from Access column of LOOKUP data type
    By Derek in forum Import/Export Data
    Replies: 1
    Last Post: 12-06-2010, 06:27 PM
  4. Automate Import of Excel data
    By tpcervelo in forum Import/Export Data
    Replies: 2
    Last Post: 07-29-2010, 12:19 AM
  5. Using Import wizard to get Excel data
    By Jack Sheet in forum Import/Export Data
    Replies: 5
    Last Post: 07-16-2010, 09:44 AM

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