Warren,
How would I modify the previous code to get the
sheet into the table?
If you only have one Worksheet in one Workbook, it might be simpler to
import manually. Here are demonstrations of how to import manually and
programmatically.
(A) To import manually:
1. Open Access and load the database.
2. Open the File menu, point to Get External Data and click Import.
3. In the Import dialog that opens, select the XLS file containing the
data and click the Import button.
4. The Import Spreadsheet Wizard should start and guide you through the
rest of the Import process.
(B) To import programmatically the first Worksheet in one Excel Workbook:
Public Sub GetOneExcelWorksheet()
' Assumes that the data in the XLS file
' is in the first Worksheet - that has any
' name, like "Sheet1" (without an apostrophe).
' This subprocedure requires a Reference
' to the Excel object library (in VBA
' Tools > References > Select Microsoft Excel).
Const CON_WORKBOOK As String = _
"C:\Documents and Settings\Owner\" _
& "Desktop\Kevin's CMS Material\" _
& "mod 2&3 CMS template.xls"
Const CON_TABLE As String = "cmsreadingstable"
DoCmd.TransferSpreadsheet acImport, _
acSpreadsheetTypeExcel9, CON_TABLE, _
CON_WORKBOOK, True
MsgBox "Finished"
End Sub
Geoff