Unable to Import Excel97-2003 Worksheet into Access (VBA)

JohanGduToit

Board Regular
Joined
Nov 12, 2021
Messages
89
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
Morning All,

I receive an Error '3274' when attempting to import an Excel 97-2003 (.xls) file into Access.

ImportError.jpg


Current Code:

VBA Code:
DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel8, "CRAZY_RAW", fWorkingPath & fName, False

I would have thought that acSpreadsheetTypeExcel8 would cater for the fact that the file is a Excel 97-2003 (.xls) file; but it does not work.

Any help would be greatly appreciated!!
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
What exactly are the values of fWorkingPath & fName?
 
Upvote 0
When trying to open the file with Office Professional Plus 2013 I get this message:

1647001850440.png
 
Upvote 0
Is "Temp" supposed to be the last subfolder (just making sure that you aren't missing a "/", as people sometimes forget to put it after the last file path and before the file name.

Are you able to open this file directly in Excel? If not, I doubt that you can import it into Access, as that would mean there is probably something wrong with it.
Where is this file being created?
Does it contain VBA code?
 
Upvote 0
When opening the "xls" file with Notepad, it looks like this....so I'm thinking that the file may be in another format; but named with an .xls extension (for whatever reason?)

1647002074533.png
 
Upvote 0
Is "Temp" supposed to be the last subfolder (just making sure that you aren't missing a "/", as people sometimes forget to put it after the last file path and before the file name.

Are you able to open this file directly in Excel? If not, I doubt that you can import it into Access, as that would mean there is probably something wrong with it.
Where is this file being created?
Does it contain VBA code?
Correct, "Temp" is the last folder and I do have the "\" before the filename.

When opening the file in Excel, I get:

1647002284133.png
 
Upvote 0
The file do not contain any vb code and gets sent to us from a supplier. I then reformat the original file (by removing top row and some columns and save the file. I then try to import it into Access and it's then that I get the error.
 
Upvote 0
When opening the "xls" file with Notepad, it looks like this....so I'm thinking that the file may be in another format; but named with an .xls extension (for whatever reason?)

View attachment 59800
If you can open the file in NotePad, and it looks like that, it is definitely NOT an Excel file. An Excel file would not look like that. There would be a whole bunch of formatting code, and it would be pretty much non-readable in NotePad.

What you have there is a straight text file. From the looks of it, it is probably a tab-delimited text file. You would use the "TransferText" command on a text file, not "TransferSpreadsheet". You may need to change the extention from "xls" to "txt".

I would first manually import the file once using the Text Import Wizard, and then saving the Import Specification. Then you can use that Import Specification in your "TransferText" command to tell Access how the file is to be parsed.
 
Upvote 0
Solution

Forum statistics

Threads
1,223,534
Messages
6,172,888
Members
452,486
Latest member
standw01

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top