TransferSpreadsheet Method

Applies To

DoCmd Object.

Description

The TransferSpreadsheet method carries out the TransferSpreadsheet action in Visual Basic. For more information on how the action and its arguments work, see the action topic.

Syntax

DoCmd.TransferSpreadsheet [transfertype] [, spreadsheettype], tablename,filename [, hasfieldnames] [, range]

The TransferSpreadsheet method uses the following arguments.

Argument

Description

transfertype

One of the following intrinsic constants:

acImport

If you leave this argument blank, the default (acImport) is assumed

spreadsheettype

One of the following numeric settings:

0 Microsoft Excel version 3.0
Lotus (WK1)
Lotus (WK3)
Lotus (WJ2) — Japanese version only
Microsoft Excel version 5.0 and version 7.0
Microsoft Excel version 4.0
Lotus (WK4)

Note You can import, export, and link spreadsheet data from Microsoft Excel spreadsheets, but you can only import and export data from Lotus spreadsheets. Microsoft Access also no longer supports importing, exporting, or linking data from Lotus (WKS) or Microsoft Excel version 2.0 spreadsheets.

If you leave this argument blank, the default (Microsoft Excel 3) is assumed.


tablename

A string expression that is the name of the Microsoft Access table you want to import spreadsheet data into, export spreadsheet data from, or link spreadsheet data to, or the Microsoft Access select query whose results you want to export to a spreadsheet.

filename

A string expression that is the file name and path of the spreadsheet you want to import from, export to, or link to.

hasfieldnames

Use True (-1) to use the first row of the spreadsheet as field names when importing, exporting, 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.

range

A string expression that is 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.


Remarks

You can leave an optional argument blank in the middle of the syntax, but you must include the argument’s comma. If you leave a trailing argument blank, don’t use a comma following the last argument you specify.

See Also

DoCmd Object, OutputTo Method, SendObject Method, TransferDatabase Method, TransferSpreadsheet Action, TransferText Method.

Example

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


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