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.
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.
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.
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.
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
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With