View Full Version : Importing Spreadsheet


RWALTZ
12-21-2006, 07:24 PM
I am trying to develop a Macro to import a Excel spreadsheet into an Access Table. I can do this if the first worksheet is the proper one. I tried to designate the file name: S:pas\production\test.xls\maintenance
where maitenance is the worksheet Tab. It works fine, if I do not include the "maitenance" Tab as long as "Maintenance" is the first Tab. How can I import a Tab that is not the first. What is the proper way to designate the Tab. I also tried:
maitenance! and this did not work. It gives me an error of improper file path.
Thanks

boblarson
12-21-2006, 07:41 PM
Believe it, or not, the VBA help file is actually very helpful.

Quoting from it:

expression.TransferSpreadsheet(TransferType, SpreadsheetType, TableName, FileName, HasFieldNames, Range, UseOA)
...
Range Optional Variant. A string expression that's a valid range of cells or the name of a range in the spreadsheet. This argument applies only to importing. Leave this argument blank to import the entire spreadsheet. When you export to a spreadsheet, you must leave this argument blank. If you enter a range, the export will fail.


Here's a sample:

DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel9, "YourTableNameHere", "YourFileNameHere", , "Maintenance!A:G"