访问Office应用程序状态栏中的进度栏

Jon*_*old 5 excel vba ms-word ms-office progress-bar

我为Word和Excel构建VBA应用程序,有没有办法访问有时出现在Office状态栏中的进度条.

Car*_*l G 4

下面将模拟 Excel 状态栏中的进度条:

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
Run Code Online (Sandbox Code Playgroud)