Microsoft KB Archive/210379

= ACC2000: How to Import an Entire Worksheet from an Excel Workbook =

Article ID: 210379

Article Last Modified on 6/23/2005

-

APPLIES TO


 * Microsoft Excel 2000 Standard Edition
 * Microsoft Access 2000 Standard Edition

-



This article was previously published under Q210379



Advanced: Requires expert coding, interoperability, and multiuser skills.

This article applies to a Microsoft Access database (.mdb) and to a Microsoft Access project (.adp).



SUMMARY
This article shows you how to use Visual Basic for Applications to import an entire worksheet from a Microsoft Excel workbook without specifying a range.



MORE INFORMATION
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!'".

Keywords: kbhowto kbinterop KB210379

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.