ERROR AL EXPORTAR DATAGRID A EXCEL
Publicado por Pablo (18 intervenciones) el 17/10/2018 23:35:17
Amigos. Recurro a ustedes una vez más. Estoy exportando un datagrid a excel, y me aparece este error al ejecutar.
"object variable or with block variable not set"
Este es mi código. Ojalá puedan sacarme de ésta.
Dim xl As Object
Dim wbk As Object
Set xl = CreateObject("Excel.Application")
xl.Visible = True
Set rst5.DataSource = DataGrid1.DataSource ' EL ERROR MARCA ESTA LÍNEA
If Not rst5.EOF Then
Set wbk = xl.Workbooks.Add
wbk.Sheets(1).Range("A1").Select
wbk.ActiveSheet.Cells.CopyFromRecordset rst5
End If
Set rst5 = Nothing
"object variable or with block variable not set"
Este es mi código. Ojalá puedan sacarme de ésta.
Dim xl As Object
Dim wbk As Object
Set xl = CreateObject("Excel.Application")
xl.Visible = True
Set rst5.DataSource = DataGrid1.DataSource ' EL ERROR MARCA ESTA LÍNEA
If Not rst5.EOF Then
Set wbk = xl.Workbooks.Add
wbk.Sheets(1).Range("A1").Select
wbk.ActiveSheet.Cells.CopyFromRecordset rst5
End If
Set rst5 = Nothing
Valora esta pregunta


0