How to use DoCmd.TransferText to import a worksheet

Posted on 2006-05-18
Last Modified: 2011-10-03

i'm working in an access database and I want to import some data into a new table.
I'm using following code:
     DoCmd.TransferText acImportDelim, "", "TMP_TABLE", "c:\my_file.xls", True

But I need to import only the second sheet of my xls file.
How can I do this using the above line of code?
Question by:y_wally
    LVL 15

    Accepted Solution

    docmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel9, "TMP_TABLE", "c:\my_file.xls", true, "WorksheetName"

    Change the True to False if the first row does not contain column headings

    Author Comment

    docmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel9, "TMP_TABLE", "c:\my_file.xls!SheetName", true, "WorksheetName!A:Z"

    whereby A:Z is the range of columns you need to import.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Is Threat Intelligence?

    Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

    It took me quite some time to sort out all the different properties of combo and list boxes available from Visual Basic at run-time. Not that the documentation is lacking: the help pages are quite thorough and well written. The problem was rather wh…
    QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
    Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
    Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    12 Experts available now in Live!

    Get 1:1 Help Now