Range.CopyFromRecordset Method

Copies the contents of an ADO or DAO Recordset object onto a worksheet, beginning at the upper-left corner of the specified range.

Namespace:  Microsoft.Office.Interop.Excel
Assembly:  Microsoft.Office.Interop.Excel (in Microsoft.Office.Interop.Excel.dll)

Syntax

'Declaration
Function CopyFromRecordset ( _
    Data As Object, _
    MaxRows As Object, _
    MaxColumns As Object _
) As Integer
'Usage
Dim instance As Range
Dim Data As Object
Dim MaxRows As Object
Dim MaxColumns As Object
Dim returnValue As Integer

returnValue = instance.CopyFromRecordset(Data, _
    MaxRows, MaxColumns)
int CopyFromRecordset(
    Object Data,
    Object MaxRows,
    Object MaxColumns
)

Parameters

  • Data
    Type: System.Object

    Required Object. The Recordset object to copy into the range.

  • MaxRows
    Type: System.Object

    Optional Object. 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
    Type: System.Object

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

Return Value

Type: System.Int32

Remarks

If the Recordset object contains fields with OLE objects in them, this method fails.

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

See Also

Reference

Range Interface

Range Members

Microsoft.Office.Interop.Excel Namespace