import spreadsheet error on column headers

J

jenny

Hi,

When I tried to run a VB code to import 5 files into the access database, I
found that some the column headers are different from my Excel file. The
Excel headers doesn't contain '#' but the Access headers contains '#'. Even
more strange, it only happened to particular files, not all 5 files.

But when I tried to manually import using the wizard, I got no problems. Pls
help!!
The below is the code I used:

ImportSheet(1) = "A_R11"
ImportSheet(2) = "B_R11"
ImportSheet(3) = "C_R11"
ImportSheet(4) = "D_R11"
ImportSheet(5) = "E_R11"

With DoCmd
For Counter = 1 To 5
.DeleteObject acTable, ImportSheet(Counter)
.TransferSpreadsheet acImport, acSpreadsheetTypeExcel9, _
ImportSheet(Counter), FileName, -1, ImportSheet(Counter) &
"!A1:IV65536"
Next Counter
End With
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top