Results 1 to 4 of 4
  1. #1
    shepa006 is offline Novice
    Windows 8 Access 2010 64bit
    Join Date
    Apr 2015
    Posts
    2

    Open Import Excel from Macro


    This is similar to other posts but I couldn't find one that answered exactly what I'm trying to do.

    Ultimately I need to let the user import an Excel worksheet, without being an Admin on their machine, and capture the name of the imported worksheet and the name of the table they created/imported to. My thoughts were
    1) From a macro, or VBA, open the built in Excel import wizard (External Data > Excel [Import & Link Group]). From what I can tell opening this from a macro should be possible. However, when I create a new macro and go to the Action Catalog > Actions > Data Import/Export there isn't an option in the catalog for importing anything from Excel. So I tried going through VBA, I don't see anything about being able to launch the Excel Import wizard there either. Since the Excel file AND worksheet will be changing and need to be specified by the user I haven't found anything in VBA that gets me to that level. I did find examples on using the import worksheet command but that assumes that you already know the worksheet name (the excel file path can be figured out with a file dialog).

    Any ideas? I don't know why the Action Catalog doesn't have a reference for opening the import excel wizard.

    2) Assuming we can get Part 1, above, working how could I capture the worksheet name or at the very least the name of the table?

    Thanks.

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,527
    You don't want it import to whatever the sheet name is.
    you want to import to the same table over and over. Add importDate field too.

    save the workbook to the same folder, with the same workbook name...say ImportBook.xlsx
    then run the macro that has
    importspreadsheet, //path/ImportBook.xlsx.

    this is the easiest method.... Save XL file, click macro button.

  3. #3
    shepa006 is offline Novice
    Windows 8 Access 2010 64bit
    Join Date
    Apr 2015
    Posts
    2
    I agree that would be ideal and how I would normally handle it. However for this situation I need to import their original table for archiving and then I have some light weight ETL functions written for validating the data from their 'archived' table and standardizing values before loading it into the final table. So I can't directly import to an existing table nor can I assume that the incoming table will be formatted properly or consistently named (file or worksheet).

  4. #4
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    So the biggest hurdle is getting the Worksheet name? I suppose there would be a .Name property for the worksheet that would be accessible via VBA. Maybe a For Each MyWorksheet in MyWorkbook...

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

Similar Threads

  1. Import Excel File using a Macro
    By smakkiee in forum Access
    Replies: 6
    Last Post: 04-28-2014, 08:45 AM
  2. Replies: 1
    Last Post: 03-11-2014, 09:29 AM
  3. Excel Import Macro Help in Access
    By vennies83 in forum Import/Export Data
    Replies: 5
    Last Post: 11-02-2011, 09:24 AM
  4. Import Excel File Using Macro?
    By oregoncrete in forum Import/Export Data
    Replies: 0
    Last Post: 04-05-2011, 12:26 PM
  5. VBA to open excel, import on close of excel
    By bdaniel in forum Programming
    Replies: 0
    Last Post: 03-20-2010, 02:45 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