Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Access VBA Reference Specific Excel Worksheet

Posted on 2013-12-18
5
Medium Priority
?
3,185 Views
Last Modified: 2013-12-18
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.

Jacob
0
Comment
Question by:Chi Is Current
  • 3
5 Comments
 
LVL 53

Expert Comment

by:Rgonzo1971
ID: 39726096
Hi,

pls try

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

Open in new window

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

Open in new window

Regards
0
 
LVL 52

Accepted Solution

by:
Gustav Brock earned 2000 total points
ID: 39726097
It is something like:

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

/gustav
0
 
LVL 2

Author Comment

by:Chi Is Current
ID: 39728164
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!

???
0
 
LVL 2

Author Comment

by:Chi Is Current
ID: 39728194
Ahhhhhhhhh......
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...
0
 
LVL 2

Author Comment

by:Chi Is Current
ID: 39728226
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???
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Code that checks the QuickBooks schema table for non-updateable fields and then disables those controls on a form so users don't try to update them.
If you need to forecast numbers -- typically for finance -- the Windows and Mac versions of Excel 2016 have a basket of tools to get the job done.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

916 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