Todd -<br><br>Here's a function I wrote to copy from a datacontrol to a spreadsheet. You should be able to easily adapt it to only copying one row of data!<br><br>There's some debug code in there (the block of code surrounded by '#' marked lines). I use a compiler variable called 'dodebug' to switch in/out my debug statements. I set it to various values to enable different levels of debugging (just '1', in this case).<br><br>Chip H.<br><br><br><FONT FACE=monospace>Public Sub DoCopyToExcel(dc As Data)<br> <br> Dim xlApp As Object<br> Dim xlSheet As Object<br> Dim xlRange As Object<br> Dim i As Long<br> Dim j As Long<br> Dim iAnswer As Integer<br> Const EXCEL_OLE_KEY = "Excel.Application"<br> Dim ColumnCount As Long<br> Dim RowCount As Long<br> Dim RangeName As String<br> <br> On Error Resume Next<br> Screen.MousePointer = vbHourglass<br> <br> Set xlApp = GetObject(, EXCEL_OLE_KEY)<br> If Err.Number <> 0 Then<br> 'Excel was not running<br> Err.Clear<br> On Error Resume Next<br> Set xlApp = CreateObject(EXCEL_OLE_KEY)<br> If Err.Number <> 0 Then<br> Set xlApp = Nothing<br> Screen.MousePointer = vbDefault<br> MsgBox "Unable to start a copy of Excel.", vbOKOnly, "Error"<br> Exit Sub '<-------<br> End If<br> End If<br> Err.Clear<br><br> On Error GoTo DoCopyToExcel_Err<br> <br> ' Hide excel while performing stuff below.<br> xlApp.Visible = False<br> xlApp.DisplayAlerts = False<br> xlApp.workbooks.Add<br> xlApp.workbooks(1).Activate<br> Set xlSheet = xlApp.ActiveSheet<br> dc.Recordset.MoveFirst<br> ColumnCount = dc.Recordset.Fields.Count<br> RowCount = dc.Recordset.RecordCount<br> <br> For i = 1 To RowCount + 1<br> For j = 1 To ColumnCount<br> #If dodebug > 1 Then<br> MsgBox "Before setting cell(" & CStr(i) & "," & CStr(j) & "

to value: " & dc.Recordset.Fields(j - 1)<br> #End If<br><br> If i = 1 Then<br> 'show column headings<br> Set xlRange = xlSheet.Cells(i, j)<br> xlRange.Value = dc.Recordset.Fields(j - 1).Name<br> <br> Else<br> Set xlRange = xlSheet.Cells(i, j)<br> xlRange.Value = CStr(dc.Recordset.Fields(j - 1))<br> <br> End If<br> <br> Set xlRange = Nothing<br> Next j<br> <br> If i > 1 Then<br> dc.Recordset.MoveNext<br> <br> ' Give user a chance to bail out<br> If i Mod 200 = 0 Then<br> iAnswer = MsgBox("200 rows done. Continue?", vbYesNo, "Confirm"

<br> If iAnswer = vbNo Then<br> Exit For '<=======<br> End If<br> End If<br> End If<br> Next i<br> <br> RangeName = NumberToExcelColumn(1) & ":" & NumberToExcelColumn(ColumnCount)<br> Set xlRange = xlSheet.Columns(RangeName)<br> xlRange.AutoFit<br> <br> xlApp.Visible = True<br> <br> Set xlRange = Nothing<br> Set xlSheet = Nothing<br> Set xlApp = Nothing<br> Screen.MousePointer = vbDefault<br> Exit Sub '<-------<br> <br>DoCopyToExcel_Err:<br> Set xlApp = Nothing<br> Screen.MousePointer = vbDefault<br> Exit Sub '<-------<br> <br>End Sub<br><br>Private Function NumberToExcelColumn(lColNum As Long) As String<br> <br> Dim RVal As String<br><br> If lColNum <= 26 Then<br> RVal = Chr$(lColNum + Asc("A"

- 1)<br> Else<br> RVal = Chr$((lColNum Mod 26) + Asc("A"

- 1)<br> RVal = Chr$((lColNum \ 26) + Asc("A"

- 1) & RVal<br> End If<br> <br> NumberToExcelColumn = RVal<br>End Function<br></font><br><br>