Excel file without header into access

ria_arora

Registered User.
Local time
Today, 08:30
Joined
Jan 22, 2011
Messages
56
Dear Friends,

I need to import Excel file into access table using VBA code and Excel file DOES NOT have any column heading. Any idea how to do import data without changing the file.

Thanks
Ria
 
Create a 'Import Specification'

Select the table in your database, right click and choose import, and create the import specificaiton from there. Then you can simply refer to the import specification in your code
 
Dear Charles,

Thanks for the prompt reply. I need to do this using VBA not manually. Please send me the sample code if you have.

Thanks and regards
Ria
 
Looking something which can be done without creating the tmp table?
 
Like Charles mentioned, first create an Import Specification manually, then you can use that one Import Spec in code for any Excel spreadsheet.

You haven't even mentioned what your main goal is.
 
We get the file without header and I have table in MS Access database with all the fields but we don't want to change the file manually.

No of records also very every month.

Thanks
Ria
 
when you say Excel file do you mean a csv or an xls

a csv is imported with docmd.transfertext, and you CAN specify which columns you import, with a file import specification

a xls is imported with docmd.transferspreadsheet, and you get rather less control. Access makes its own mind up about what format columns are, and sometimes gets it wrong - and you can't use a file import spec.

With an xls, you have two options
a) import based on column headers, irrespective of the actual column order OR
b) import respecting the column order, ignoring the column headers

given you don't have headers, you can just use option b.
 

Users who are viewing this thread

Back
Top Bottom