Exportar a excel datagrid
Publicado por Mariano (51 intervenciones) el 08/06/2018 17:34:27
hola tengo este codigo en VB6.0 con base de datos acces me da error
el error lo tengo en la linea que tiene la cara
osea me lo exporta pero me obliga a cerrar el sistema
Desde ya gracias
el error lo tengo en la linea que tiene la cara
osea me lo exporta pero me obliga a cerrar el sistema
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
Dim i As Integer, j As Integer, icol As Integer
If nfilas = 1 Then
MsgBox "Nohay datos que enviar a Excel": Exit Sub
Else
Set objExcel = CreateObject("Excel.application")
Set xlibro = objExcel.Workbooks.Add(App.Path & "\ProductosSalida.xls")
objExcel.Visible = True
Set hoja = objExcel.ActiveSheet
icol = 0
For i = 1 To datagrid.Columns.Count - 1
If datagrid.Columns(i).Visible Then
icol = icol + 1
hoja.Cells(1, icol) = datagrid.Columns(i).Caption
For j = 0 To nfilas - 1
='/img/emoticons/omg.gif' width='22' height='22' border='0' /> hoja.Cells(j + 2, icol) = datagrid.Columns(i).CellValue(datagrid.GetBookmark(j))
Next
End If
Next
hoja.Rows(1).Font.Bold = True
hoja.Rows(1).Font.Color = vbBlack
hoja.Columns("A:Z").AutoFit
End If
Set hoja = Nothing
Set xlibro = Nothing
Set objExcel = Nothing
Desde ya gracias
Valora esta pregunta


0