Consulting

Results 1 to 5 of 5

Thread: Sleeper: Progressor in status bar

  1. #1
    VBAX Mentor
    Joined
    Jun 2005
    Posts
    374
    Location

    Sleeper: Progressor in status bar

    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
    moshe

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    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.

  3. #3
    VBAX Mentor
    Joined
    Jun 2005
    Posts
    374
    Location
    hello

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

  4. #4
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Quote Originally Posted by lior03
    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.

  5. #5
    VBAX Mentor CBrine's Avatar
    Joined
    Jun 2004
    Location
    Toronto, Canada
    Posts
    387
    Location
    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
    The most difficult errors to resolve are the one's you know you didn't make.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •