Start Free Trial
Come for the solution, stay for everything else.
Start Free Trial
Transferspreadsheet 31519 error
I am trying to import an Excel .xlsx file into Access using VB code and receive a 31519 error ("You can not import this file") followed by error 424 ("Object required")
DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel9, "table name", GetFile, True
GetFile = the Excel file name
What am I missing?
thanks for your help
8/22/2022 - Mon
the acSpreadsheetTypeExcel9 is the Microsoft Excel 2000 format. The .xlsx is a 2007 or above extension.
Then what version of Access and what version of the DB are you doing this in?
And is the GetFile the full path like
The GetFile code works in another app...
DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel12, "tablename", GetFile, True
I tried acSpreadsheetTypeExcel9 to see if that made a difference -- but still get the same error with 9 and 12 in the new app -- same code. So it's odd that it woks in one place and not another.
I have a similar function that imports .csv text file and have no issues.
thanks again for the help
What is the source for the SS?
One I ran into was that my CRM would export the query results as a file with an .xls extension. It would open fine in in Excel, but a straight import into Access would fail.
It took forever to figure it out. Then I opened the file with a text editor instead and it turned out to be an XML file with an Excel header string. Excel did the conversion -- but Access couldn't understand it.
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
I am tring to IMPORT -- not export... ?
I understand you want to import.
I'm saying what is the Excel SS source? Is it a website or something similar? Are you sure it is a true Excel file that has been edited by Excel?
Yes... Sorry I misunderstood your question
I am able to open it in Excel. It has a .xlsx extension.
What else should I be looking for? Thanks
to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
Even though it has an xlsx until you actually edit and save the file it may still be XML file under the covers. Right click the file and do an Open With and select Notepad and see what it looks like in the guts.
As Jim P mentioned, and I think you indicated, it may show up as xlsx but have XML "under the covers". If you preceed your Transferspreadsheet with a segment of code that actually opens the Excel workbook using automation and then does a SaveAs with an xlsx file, you may find that you are able to read it properly with TransferSpreadsheet.
Give it a try by doing it manually.
Scott McDaniel (EE MVE )
<no points please>
I too have had issues with files that pretend to be xls or xlsx files, especially those that come down from internet portals. One of my clients downloads a file every day from their vendor portal, and uses a utility I created to import that file into their database. They ALWAYS review the file before importing, so I don't automatically SaveAs in my code, but instead have instructed them to do so.
About once a month I get an email saying the utility won't work. About an hour after that, I get an email saying that they forgot to do the SaveAs portion of the process ...
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
I am able to import the xls file manually - but get the 31519 error when trying to use the transferspreadsheet vba.
I managed to get around it by saving the .xls as a .csv file -- and the transfertext option works.
Thanks for all your input.
Do you know of any automated way to save .xls files to .cvs?
ASKER CERTIFIED SOLUTION
Log in or sign up to see answer
Become an EE member today
7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
thanks for your help!
Plans and Pricing
Certified Expert Program
© 1996-2022 Experts Exchange, LLC. All rights reserved. Covered by US Patent