Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements.
To import an entire worksheet, refer to the worksheet without a named
range, but include an exclamation point (!). For example, the following
sample code imports Sheet5 from a workbook named T.xls located on drive C.
Function ImportXL()
DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel9, _
"TestTable", "C:\T.XLS", True, "Sheet5!"
End Function
If you do not specify a value for the last argument, Microsoft Access
imports the first worksheet that it finds in the workbook. If you specify a
range, that range is imported from the first worksheet in the
workbook. To specify a range from a specific worksheet, use the following syntax, which refers to cells A1 through G50:
Sheet5!A1:G50
NOTE: If the sheet name contains a special character, you must enclose it in apostrophes (' '); otherwise, you receive a run-time error. For example, if the sheet has the name Test#Sheet, the last argument would be "'Test#Sheet!'".