This documentation is archived and is not being maintained.

DoCmd.TransferSpreadsheet Method

Office 2007
The TransferSpreadsheet method carries out the TransferSpreadsheet action in Visual Basic.


expression.TransferSpreadsheet(TransferType, SpreadsheetType, TableName, FileName, HasFieldNames, Range, UseOA)

expression   A variable that represents a DoCmd object.


NameRequired/OptionalData TypeDescription
TransferTypeOptionalAcDataTransferTypeThe type of transfer you want to make. The default value is acImport.
SpreadsheetTypeOptionalAcSpreadSheetTypeThe type of spreadsheet to import from, export to, or link to.
TableNameOptionalVariantA string expression that is the name of the Microsoft Office Access table you want to import spreadsheet data into, export spreadsheet data from, or link spreadsheet data to, or the Access select query whose results you want to export to a spreadsheet.
FileNameOptionalVariantA string expression that's the file name and path of the spreadsheet you want to import from, export to, or link to.
HasFieldNamesOptionalVariantUse True (–1) to use the first row of the spreadsheet as field names when importing or linking. Use False (0) to treat the first row of the spreadsheet as normal data. If you leave this argument blank, the default (False) is assumed. When you export Access table or select query data to a spreadsheet, the field names are inserted into the first row of the spreadsheet no matter what you enter for this argument.
RangeOptionalVariantA 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.
UseOAOptionalVariantThis argument is not supported.


You can use the TransferSpreadsheet method to import or export data between the current Access database or Access project (.adp) and a spreadsheet file. You can also link the data in a Microsoft Excel spreadsheet to the current Access database. With a linked spreadsheet, you can view and edit the spreadsheet data with Access while still allowing complete access to the data from your Excel spreadsheet program. You can also link to data in a Lotus 1-2-3 spreadsheet file, but this data is read-only in Access.

Bb214134.vs_note(en-us,office.12).gif  Note
You can also use ActiveX Data Objects (ADO) to create a link by using the ActiveConnection property for the Recordset object.


The following example imports the data from the specified range of the Lotus spreadsheet Newemps.wk3 into the Access Employees table. It uses the first row of the spreadsheet as field names.

Visual Basic for Applications
DoCmd.TransferSpreadsheet acImport, 3, _
    "Employees","C:\Lotus\Newemps.wk3", True, "A1:G12"