I'm getting an Automation Error when attempting to use CopyFromRecordset to dump the contents of a recordset created in VB6 to Excel. Here is my codeThe error occurs on the highlighted line, and here is the error.VB Code:
Dim oXlApp As Object, oXLWb As Object, oXLWs As Object Dim vRecArray As Variant Dim lRecCount As Long Dim iFldCount As Integer, iCol As Integer, iRow As Integer 'Create an instance of Excel and add a workbook Set oXlApp = CreateObject("Excel.Application") Set oXLWb = oXlApp.Workbooks.Add Set oXLWs = oXLWb.Worksheets("Sheet1") 'Display Excel and give user control of Excel's lifetime oXlApp.Visible = True oXlApp.UserControl = True 'Copy field names to the first row of the worksheet iFldCount = adoRS.Fields.Count For iCol = 1 To iFldCount oXLWs.Cells(1, iCol).Value = adoRS.Fields(iCol - 1).Name Next iCol [HL="#FFFF80"]oXLWs.Cells(2, 1).CopyFromRecordset adoRS[/HL]




Reply With Quote