Results 1 to 8 of 8
  1. #1
    lere is offline Novice
    Windows 8 Access 2007
    Join Date
    Feb 2017
    Posts
    6

    Exclamation Macro to automatically import an excel file in a certain poisition???

    Hello everyone! I'm working on Access trying to create a system to elaborate orders of a small company and generate offers.
    I'd like to create a Macro connected to a button which enables the user to automatically import datas from an excel file without specifying which excel file : in other words, I want to tell the system just where to grab the file and not which file, because the button should work for multiple files (orders) that I recieve and not just one, or, eventually, I want t be able to choose which file to import after I click the button.
    I'm sorry for my english! I hope you can help me


    R.

  2. #2
    ranman256's Avatar
    ranman256 is online now VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,524
    you cant have it both ways,
    do you want to pick the file ?
    or
    import all files in the folder?

    the macro can do either.

  3. #3
    lere is offline Novice
    Windows 8 Access 2007
    Join Date
    Feb 2017
    Posts
    6
    I'd prefer to pick the file!

  4. #4
    aytee111 is offline Competent At Times
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    Here are some step-by-step instructions: http://smallbusiness.chron.com/impor...cro-42538.html

  5. #5
    lere is offline Novice
    Windows 8 Access 2007
    Join Date
    Feb 2017
    Posts
    6
    Thank you, but that doesn't answer my question: I already know how to import a file with a macro, what I wanna do is Create a Macro which imports a file in a specific folder, without saying which file, meaning that I can change that file in that folder and the macro still opens it.

  6. #6
    aytee111 is offline Competent At Times
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    I am not a macro user, but after some research I have found that this cannot be done in a macro. If you want to be able to browse for a file then it has to be done in VBA. Another way is to prompt the user for a file name and they type it in.

  7. #7
    lere is offline Novice
    Windows 8 Access 2007
    Join Date
    Feb 2017
    Posts
    6
    Thank you! and how can I write in VBA in Access? and then Create a sort of "BUTTON" that enables me to choose which file to import?

  8. #8
    aytee111 is offline Competent At Times
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    First, convert your macro to VBA (there is a button for that). Then use this code: http://www.minnesotaithub.com/2013/0...cess-with-vba/
    In VBA, you would add this:
    Dim FileName as String
    FileName=SelectFile()
    If IsNull(FileName)
    MsgBox "Cancelled"
    Else
    ....import the file
    End If

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

Similar Threads

  1. Import Excel file into an existing table via a macro
    By Gaby2811 in forum Import/Export Data
    Replies: 3
    Last Post: 09-23-2016, 06:12 AM
  2. Replies: 1
    Last Post: 08-18-2016, 11:44 AM
  3. Import Excel File using a Macro
    By smakkiee in forum Access
    Replies: 6
    Last Post: 04-28-2014, 08:45 AM
  4. Replies: 2
    Last Post: 10-05-2012, 01:50 PM
  5. Import Excel File Using Macro?
    By oregoncrete in forum Import/Export Data
    Replies: 0
    Last Post: 04-05-2011, 12:26 PM

Tags for this Thread

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