Hola, que hay?
Quiero poner una barra de progreso en un código que suele tardar como
1 minuto y medio en terminarse y la verdad, hay veces que no se si se
ha bloqueado o está trabajando.
La barra de progreso que me habia gustado era la que tiene dos barras
en un mismo formulario, he descargado el ejemplo de esta dirección:
http://www.erlandsendata.no/downloa...amples.zip
la opción 3, el formulario se llama "ProgressDlg2".
Lo que pasa es qeu no se aplicarlo a mi código, no se donde tengo que
ponerlo.
Mi código es este:
Sub EjecutarTodo()
'
' EjecutarTodo Macro
' Macro grabada el 17/08/2006 por Jose
'
'
inicio = Time
Sheets("ori").Select
Call ListarArchivosEnCarpeta
Sheets("500").Select
Call ListarArchivosEnCarpeta
Sheets("th").Select
Call ListarArchivosEnCarpeta
Sheets("Unión").Select
Call PegarFormulas
Sheets("Parámetros").Select
fin = Time
tiempo = fin - inicio
Range("B24") = (Format(tiempo, "nn") & " min. " & Format(tiempo,
"ss") & " seg.")
Range("B25").Select
End Sub
Por si no os hace falta descargar el archivo os pongo aquí el código
de ejemplo:
Para llamar al formulario:
Sub ShowDialog2()
Load ProgressDlg2
ProgressDlg2.Show
End Sub
Código del formulario:
Option Explicit
Private Sub UserForm_Activate()
Call Main2
End Sub
Private Sub UserForm_Initialize()
With Me.lblDone ' set the "progress bar" to it's initial length
.Top = Me.lblRemain.Top + 1
.Left = Me.lblRemain.Left + 1
.Height = Me.lblRemain.Height - 2
.Width = 0
End With
With Me.lblDone2 ' set the "progress bar" to it's initial length
.Top = Me.lblRemain2.Top + 1
.Left = Me.lblRemain2.Left + 1
.Height = Me.lblRemain2.Height - 2
.Width = 0
End With
End Sub
Código del módulo:
Sub Main2()
Dim i As Long, tot As Long
Dim j As Long, totJ As Long
tot = 5000
totJ = 5
ProgressDlg2.Caption = "Progress Dialog Title"
For j = 1 To totJ
For i = 1 To tot
If i Mod 10 = 0 Then ProgressBar2 "Copying file " & j & "
of " & totJ, j / totJ, "Writing record " & i & " of " & tot, i / tot
' do something
Next i
Next j
Unload ProgressDlg2
End Sub
Leer las respuestas