Excel file without header into access (1 Viewer)

ria_arora

Registered User.
Local time
Today, 11:33
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
 

CharlesWhiteman

Registered User.
Local time
Today, 04:33
Joined
Feb 26, 2007
Messages
421
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
 

ria_arora

Registered User.
Local time
Today, 11:33
Joined
Jan 22, 2011
Messages
56
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
 

ria_arora

Registered User.
Local time
Today, 11:33
Joined
Jan 22, 2011
Messages
56
Looking something which can be done without creating the tmp table?
 

vbaInet

AWF VIP
Local time
Today, 04:33
Joined
Jan 22, 2010
Messages
26,374
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.
 

ria_arora

Registered User.
Local time
Today, 11:33
Joined
Jan 22, 2011
Messages
56
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
 

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 04:33
Joined
Sep 12, 2006
Messages
15,695
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

Top Bottom