Ver Mensaje Individual
  #2 (permalink)  
Antiguo 18-08-2005, 16:29:01
miguel_1969 miguel_1969 is offline
Gran Participación en el Foro
 
Registrado: oct 2004
Posts: 165
miguel_1969 Valoración +2
Predeterminado

Hola huevo.

Te paso un código que uso para pasar un recordset a excel:

Private Sub mnuGenerarinforme_Click()
Dim Xlapp As Excel.Application
Dim Prueba As Excel.Workbook
Dim Totalreg As Double
Dim Totalcol As Integer

Set Xlapp = New Excel.Application
Xlapp.Workbooks.Add

Set Prueba = Xlapp.Workbooks(Xlapp.Workbooks.Count)
Set Hoja1 = Prueba.Worksheets.Add

Recordset.MoveLast

Totalreg = Recordset.RecordCount

Recordset.MoveFirst

Totalcol = DataGrid.Columns.Count

For i = 0 To Totalcol - 1
Hoja1.Cells(1, i + 1).Value = Recordset.Fields(i).Name
Next i

Hoja1.Range("A3").CopyFromRecordset Recordset

Prueba.SaveAs (Prueba.xls)

Set Hoja1 = Nothing
Set Prueba = Nothing
Set Xlapp = Nothing
End Sub
Responder Con Cita