[Webinar] Streamline your web hosting managementRegister Today

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3353
  • Last Modified:

Access VBA Reference Specific Excel Worksheet

Hello ~  I'm looking for the syntax to reference a specific worksheet within an Excel file, "Song.xlsx", to import into an Access table.  The worksheet is the #2 tab and is named "Tune".

I have tried:

DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel12Xml, "tblTest", "U:\Song.xlsx.Sheets(2)", True

DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel12Xml, "tblTest", "U:\Song.xlsx.Sheets(Tune)", True

No Joy!

'Would appreciate ideas.
'Will ck back in AM.

Chi Is Current
Chi Is Current
  • 3
1 Solution

pls try

DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel12Xml, "tblTest", "U:\Song.xlsx", True, "Tune!"

Open in new window

DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel12Xml, "tblTest", "U:\Song.xlsx", True, "Tune!A1:C5"

Open in new window

Gustav BrockCIOCommented:
It is something like:

DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel12Xml, "tblTest", "U:\Song.xlsx", True, "Tune$"

Chi Is CurrentAuthor Commented:
Hello  Rgonzo1971 and /Gustav ~

Thank you both for your replies.

Examples: #1 and #3, above, DO run, DO create a new table and DO find the "Tune" tab (!);
however both print only column names and neither imports any of the data on the spreadsheet!

Chi Is CurrentAuthor Commented:
Looking at the import Errors log, I'm seeing many "Type Conversion Failure" errors.

I'm surprised, as the tblTEST is being created each time...
Chi Is CurrentAuthor Commented:
OOOOOOOOOOK, I am seeing "Type Conversion Failure" errors for data in fields that does not conform to datatype of the target table's fields.

Even when all target table fields' datatypes are set to TEXT, import fails for records containing HYPHENS in some fields....

Any way to allow importing hyphens into text fields???

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now