Problema de exportar datos a excel
Hola!! Tengo una pregunta tengo el siguiente codigo pero me aparece un error (mostrado en la parte inferior en ** y ++) y no entiendo la razon. Espero que me puedas ayudar ya que me urge un poco... Gracias
Dim rst As Recordset
Dim I As Long
Dim xlApp 'Referencia de programa Excel
Dim xlBook As Excel.Workbook 'Referencia a un libro Excel ++++*******************No se ha definido wl tipo definido por el usuario!! Error de Compilacion********************+++++++
Dim xlSheet As Excel.Worksheet 'Referencia a la hoja 1 del Libro
Set xlApp = CreateObject("Excel.Application") 'Objeto Excel
xlApp.Visible = True 'Visible
Set xlApp = xlBook.Application
Set xlSheet = xlBook.Worksheets(1)
xlSheet.Visible = xlSheetVisible
Set rst = Me.Subformulario_TbCalCursoPrimeCaptura.Form.Recordset
rst.MoveFirst
I = 1
With rst
Do While Not rst.EOF
xlSheet.Cells(I, 1) = !num_empleado
xlSheet.Cells(I, 2) = !ap_paterno
xlSheet.Cells(I, 3) = !ap_materno
xlSheet.Cells(I, 4) = !nom_alumno
xlSheet.Cells(I, 5) = !DEPTO
xlSheet.Cells(I, 6) = !TEM
xlSheet.Cells(I, 7) = !CLAVE
rst.MoveNext
I = I + 1
Loop
End With
Set xlSheet = Nothing
Set xlBook = Nothing
Set xlApp = Nothing
MsgBox "Exportación a Excel Terminada con éxito.", vbApplicationModal + vbInformation + vbOKOnly, "Exportar A Excel"
Dim rst As Recordset
Dim I As Long
Dim xlApp 'Referencia de programa Excel
Dim xlBook As Excel.Workbook 'Referencia a un libro Excel ++++*******************No se ha definido wl tipo definido por el usuario!! Error de Compilacion********************+++++++
Dim xlSheet As Excel.Worksheet 'Referencia a la hoja 1 del Libro
Set xlApp = CreateObject("Excel.Application") 'Objeto Excel
xlApp.Visible = True 'Visible
Set xlApp = xlBook.Application
Set xlSheet = xlBook.Worksheets(1)
xlSheet.Visible = xlSheetVisible
Set rst = Me.Subformulario_TbCalCursoPrimeCaptura.Form.Recordset
rst.MoveFirst
I = 1
With rst
Do While Not rst.EOF
xlSheet.Cells(I, 1) = !num_empleado
xlSheet.Cells(I, 2) = !ap_paterno
xlSheet.Cells(I, 3) = !ap_materno
xlSheet.Cells(I, 4) = !nom_alumno
xlSheet.Cells(I, 5) = !DEPTO
xlSheet.Cells(I, 6) = !TEM
xlSheet.Cells(I, 7) = !CLAVE
rst.MoveNext
I = I + 1
Loop
End With
Set xlSheet = Nothing
Set xlBook = Nothing
Set xlApp = Nothing
MsgBox "Exportación a Excel Terminada con éxito.", vbApplicationModal + vbInformation + vbOKOnly, "Exportar A Excel"
1 Respuesta
Respuesta de fernijon
1