CopyFromRecordset Method

Microsoft Office Web Components Visual Basic

expression.CopyFromRecordset(Data, MaxRows, MaxColumns)

expression    Required. An expression that returns a Range object.

Data   Required Variant. The name of the Recordset object to copy into the range.

MaxRows   Optional Variant. The maximum number of records to copy onto the worksheet. If this argument is omitted, all the records in the Recordset object are copied.

MaxColumns   Optional Variant. The maximum number of fields to copy onto the worksheet. If this argument is omitted, all the fields in the Recordset object are copied.

Remarks

Copying begins at the current row of the Recordset object. After copying is completed, the EOF property of the Recordset object is True.

When this method copies the recordset to the worksheet, the results will be truncated if you do not specify a range that is large enough to hold the contents of the recordset.

Example

This example copies a recordset named rstAuthors into the active sheet of Spreadsheet1 starting at cell A1.

Spreadsheet1.ActiveSheet.Cells.CopyFromRecordset rstAuthors