Visual Basic - Como exportar de Datagrid a excel

Life is soft - evento anual de software empresarial
 
Vista:
sin imagen de perfil

Como exportar de Datagrid a excel

Publicado por Alejandro (11 intervenciones) el 15/02/2014 21:30:14
Tengo el sigueinte codigo pero me sale error de copilacion "no se a definido el tipo definido por el usuria" en:
Quote:
Private Sub exporte_dtg(Datagrid As Datagrid, n_Filas As Long)
On Error GoTo MensajeError

Me.MousePointer = vbHourglass

If TOTALFILAS = 0 Then
MsgBox "NO HAY DATOS"
Exit Sub
Else

Set Obj_Exel = CreateObjet("Exel.Application")
Set Obj_Libro = Obj.Exel.Workbooks.Open(App.patch & "\Libro.xls")
Set Obj_Hoja = Obj.Exel.ActiveSheet


Columna = 0
For x = 0 To LISTADO.Columns.Count - 1
If LISTADO.Columns(x).Visible Then
Columna = Columna + 1
Obj_Hoja.cells(1, Columna) = LISTADO.Columns(x).Caption
For Y = 0 To TOTALFILAS - 1
Obj_Hoja.cells(Y + 2, Columna) = LISTADO.Columns(x).CellValue(LISTADO.GetBookmark(Y ))
Next
End If
Next


Obj_Exel.Visible = True


Set Obj_Exel = Nothing
Set Obj_Hoja = Nothing
Set Obj_Libro = Nothing

Me.MousePoiter = vbDefault
Exit Sub












MensajeError:
MsgBox Err.Description, vbCritical
On Error Resume Next

Set Obj_Exel = Nothing
Set Obj_Hoja = Nothing
Set Obj_Libro = Nothing

Me.MousePoiter = vbDefault

End Sub

Private Sub Command3_Click()
Call exporte_dtg(LISTADO, LISTADO.ApproxCount)

End Sub
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder