Results 1 to 4 of 4
  1. #1
    ricky99 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2012
    Location
    Italy
    Posts
    16

    Question Import an Excel file choosing before the sheet or the named range

    Hello everyone,
    I would like to import in Access an Excel 2007 file. The problem comes because it has:
    - several sheets;
    - every sheets with one (or more in some cases) named ranges.
    The user, by an advanced form, import in a table not only the desidered Excel file (by FileDialogPicker), but the specific named range. In other words, I need to build a form where the user can select an Excel file, then choose from a list of sheets or named ranges contained in it.
    What solutions can you propose me?
    Many thanks for your attention and help.
    Bye.



    Riccardo

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    So you need to dynamically build a RowSource list in a combobox of the sheet names and/or ranges in a selected workbook?

    Try something like:

    Dim objExc As Excel.Application
    Dim objWbk As Excel.Workbook
    Dim objWsh As Excel.Worksheet

    Set objExc = CreateObject("Excel.Application")
    objExc.Visible = True
    Set objWbk = objExc.Workbooks.Add
    For Each objWsh In objWbk.Worksheets
    List1.AddItem objWsh.Name
    Next
    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
    ricky99 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2012
    Location
    Italy
    Posts
    16
    Hello & thanks for you quick reply.
    Just few notes to you answer.
    Does the code need to open the application (Excel) to know its properties (named ranges, worksheets and so)? Ask that because the file could be quite biggy in terms of size and the procedure may take some seconds to complete.
    Bye.

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    As far as I know, yes Access must 'open' the Excel as an object that the code can manage. Once you are done retrieving the info, need to close the workbook and the Excel app. Review this thread http://forums.aspfree.com/microsoft-...el-413629.html
    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.

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

Similar Threads

  1. Replies: 2
    Last Post: 08-14-2012, 04:24 AM
  2. Import excel worksheet by range with non identical headers
    By snoopy2003 in forum Import/Export Data
    Replies: 1
    Last Post: 03-14-2011, 01:04 AM
  3. Imported Named Range
    By jgelpi16 in forum Programming
    Replies: 4
    Last Post: 03-04-2011, 10:03 AM
  4. Import Excel sheet with query
    By tpcervelo in forum Queries
    Replies: 1
    Last Post: 08-03-2010, 07:10 PM
  5. How to import named range from excel
    By timpepu in forum Import/Export Data
    Replies: 1
    Last Post: 02-19-2010, 11:26 AM

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