View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
JKP JKP is offline
external usenet poster
 
Posts: 2
Default ADO Recordset to Excel 2007 Worksheet Cell Values via XML

HiJames,

A bit late perhaps, but I found this thread only today.

Why would you want to push the recordset into Excel using XML? Do you
know you can use the CopyFromRecordset method to write a recordset to
Excel in one go?

Example (oADOConn is an object variable that holds the connection to
the database):

sSQL = "SELECT * FROM Table"
oRS.Open sSQL, oADOconn
For Each oFld In oRS.Fields
lCount = lCount + 1
oSh.Cells(1, lCount).Value = oFld.Name
Next
If Not oRS.EOF Then
oSh.Range("A2").CopyFromRecordset oRS
End If
oRS.Close
Set oRS = Nothing