Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Accessing the progress bar in an Office application's status bar

I build VBA applications for both Word and Excel, is there any way to access the progress bar that sometimes appears in the Office status bar.

like image 839
JonnyGold Avatar asked Oct 20 '08 08:10

JonnyGold


People also ask

What is the status bar in Office?

The status bar at the bottom of Office programs displays status on options that are selected to appear on the status bar. Many options are selected by default. If you want to customize the status bar, right-click it, and then click the options that you want.

Where is the status bar access?

Show or hide the status barClick the File tab, and then click Options. The Access Options dialog box appears. In the left pane, click Current Database. Under Application Options, select or clear the Display Status Bar check box.

Is status bar and progress bar same?

The status bar enables you to give information directly to the user of your application. At the same time, it is possible to extend the status bar with your own components. In addition to the status bar, a progress bar that is able to manage and display multiple tasks at once is integrated in the application.


2 Answers

The following will simulate a progress bar in Excel's status bar:

Public Sub UpdateStatusBar(percent As Double, Optional Message As String = "")

    Const maxBars As Long = 20
    Const before As String = "["
    Const after As String = "]"

    Dim bar As String
    Dim notBar As String
    Dim numBars As Long

    bar = Chr(31)
    notBar = Chr(151)
    numBars = percent * maxBars

    Application.StatusBar = _
    before & Application.Rept(bar, numBars) & Application.Rept(notBar, maxBars - numBars) & after & " " & _
         Message & " (" & PercentageToString(percent) & "%)"

    DoEvents

End Sub
like image 176
Carl G Avatar answered Sep 23 '22 00:09

Carl G


I would recommend in addition, to record the current state of the StatusBar, then restore it when everything is done.

Dim OldStatus
With Application
    OldStatus = .DisplayStatusBar
    .DisplayStatusBar = True
    .StatusBar = "Doing my duty, please wait..."
End With
' Do what you do best here (you can refresh the .StatusBar message with updted, as needed)
With Application
    .StatusBar = False
    .DisplayStatusBar = OldStatus
End With
like image 25
KnomDeGuerre Avatar answered Sep 25 '22 00:09

KnomDeGuerre