PDA

View Full Version : Sleeper: Progressor in status bar



lior03
01-09-2006, 03:51 AM
hello
the following macro emulates the auto save add-in.
how can i add a progressor to the status bar so i have an indication as to how long it take to save a wotkbook.
can the progressor be like excel's?


Sub autosave()
Application.OnTime Now + TimeSerial(0, 0, 60), "autosave"
Dim ans As String
ans = MsgBox("autosave now ?", vbYesNo)
Select Case ans
Case vbYes
Application.StatusBar = " now save " & ActiveWorkbook.Name
ActiveWorkbook.Save
Application.StatusBar = ""
Exit Sub
Case vbNo
Exit Sub
End Select
End Sub


thanks

Bob Phillips
01-09-2006, 04:31 AM
You can't. With vba progress bar you need something that interacts with your code allowing =you to show the latest position. Once you issue a Save command you hand-off control and don't get it back again until after the file is saved.

lior03
01-09-2006, 05:00 AM
hello

is it possible to let the user decide the time inteval or should it be determined only through the code?
thanks

Bob Phillips
01-09-2006, 05:26 AM
hello

is it possible to let the user decide the time inteval or should it be determined only through the code?
thanks

It makes no difference, you do not get an opportunity to interrup the save to display progress, regardless of how the interval is determined.

CBrine
01-09-2006, 07:32 AM
Here's a neat little bit of code I use to simulate a status bar progress bar. I use Chr(129) which is a clear square box. It looks pretty good, and isn't that hard to work with. You will need to figure out the interval's you want to use.



Private Sub CommandButton1_Click()
Dim strStatus As String, intCount As Double
strStatus = "*"
strStatus = "Processing "
Do Until Len(strStatus) = 40
Application.StatusBar = strStatus
For intCount = 1 To 100000
Next
strStatus = strStatus & Chr(129)
Loop
Application.StatusBar = False
End Sub


Of course, everyone's right about needing an event that you can use to update the progress bar. The save event will not allow any updates until it's completed. This will work with a code loop.

HTH
Cal