Saludos
tengo una inquietud y quisiera que me ayudaran de ante mano un millon de gracias
tengo una funcion que me exporta los datos que tiene cargada una grilla a excel, todo perfecto
el problema es el siguiente
quisiera saber si es posible colocar un control progressbar en el form
para que este se muestre el progreso de exportacion hacia excel
esta es la funcion y el boton que me exporta:
nota: el flexgrid es llamado "grid"
Private Sub cmdExportar_Click()
If MsgBox("Esta seguro que desea Exportar Estos Cheques", vbQuestion +_ vbYesNo, "Exportar") = vbYes Then
If Exportar_Excel(App.Path & "\Reporte.xls", grid) Then
MsgBox " Datos exportados en " & App.Path, vbInformation
End If
End If
Public Function Exportar_Excel(sOutputPath As String, FlexGrid As Object)_ As Boolean
On Error GoTo Error_Handler
Dim o_Excel As Object
Dim o_Libro As Object
Dim o_Hoja As Object
Dim Fila As Long
Dim columna As Long
' -- Crea el objeto Excel, el objeto workBook y el objeto sheet
Set o_Excel = CreateObject("Excel.Application")
Set o_Libro = o_Excel.Workbooks.Add
Set o_Hoja = o_Libro.Worksheets.Add
' -- Bucle para Exportar los datos
With FlexGrid
For Fila = 1 To .Rows - 1
For columna = 0 To .Cols - 1
o_Hoja.Cells(Fila + 5, columna + 1).Value = .TextMatrix(Fila,_ columna)
o_Hoja.Cells(1, 3).Formula = Label8.Caption
o_Hoja.Cells(1, 3).Font.Size = 16
o_Hoja.Cells(1, 3).Font.Color = vbBlue
o_Hoja.Cells(1, 3).Font.Bold = True
o_Hoja.Cells(2, 4).Formula = "Reporte de Cheques"
o_Hoja.Cells(2, 4).Font.Size = 14
o_Hoja.Cells(2, 4).Font.Color = vbRed
o_Hoja.Cells(2, 4).Font.Bold = True
o_Hoja.Cells(3, 4).Formula = " Del " & fecha1.Value & " al " &_ fecha2.Value
o_Hoja.Cells(3, 4).Font.Bold = True
o_Hoja.Cells(6, 1).Formula = "Cheque"
o_Hoja.Cells(6, 1).Font.Bold = True
o_Hoja.Cells(6, 1).Font.Size = 11
o_Hoja.Cells(6, 2).Formula = "Carp"
o_Hoja.Cells(6, 2).Font.Bold = True
o_Hoja.Cells(6, 2).Font.Size = 11
o_Hoja.Cells(6, 3).Formula = "Fecha"
o_Hoja.Cells(6, 3).Font.Bold = True
o_Hoja.Cells(6, 3).Font.Size = 11
o_Hoja.Cells(6, 4).Formula = "Beneficiario"
o_Hoja.Cells(6, 4).Font.Bold = True
o_Hoja.Cells(6, 4).Font.Size = 11
o_Hoja.Cells(6, 5).Formula = "Monto en RD$"
o_Hoja.Cells(6, 5).Font.Bold = True
o_Hoja.Cells(6, 5).Font.Size = 11
o_Hoja.Cells(6, 6).Formula = "Estado"
o_Hoja.Cells(6, 6).Font.Bold = True
o_Hoja.Cells(6, 6).Font.Size = 11
Next
Next
End With
o_Libro.Close True, sOutputPath
' -- Cerrar Excel
o_Excel.Quit
' -- Terminar instancias
Call ReleaseObjects(o_Excel, o_Libro, o_Hoja)
Exportar_Excel = True
Exit Function
' -- Controlador de Errores
Error_Handler:
' -- Cierra la hoja y el la aplicación Excel
If Not o_Libro Is Nothing Then: o_Libro.Close False
If Not o_Excel Is Nothing Then: o_Excel.Quit
Call ReleaseObjects(o_Excel, o_Libro, o_Hoja)
If Err.Number <> 1004 Then MsgBox Err.Description, vbCritical
End Function
Private Sub ReleaseObjects(o_Excel As Object, o_Libro As Object, o_Hoja As Object)
If Not o_Excel Is Nothing Then Set o_Excel = Nothing
If Not o_Libro Is Nothing Then Set o_Libro = Nothing
If Not o_Hoja Is Nothing Then Set o_Hoja = Nothing
End Sub
quisiera que me ayuden por favor