문제

Word와 Excel 모두에 대한 VBA 응용 프로그램을 구축합니다. 때로는 사무실 상태 표시 줄에 나타나는 진행률 표시 줄에 액세스 할 수있는 방법이 있습니까?

도움이 되었습니까?

해결책

다음은 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

다른 팁

또한 현재 상태 막대의 상태를 기록한 다음 모든 것이 완료되면 복원하는 것이 좋습니다.

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

나는 진행률 표시 줄에 액세스하지 않았지만 과거에는 이와 같은 것을 사용하여 상태 표시 줄에 작업 상태 텍스트를 배치했습니다 ...

Sub StatusBarExample()
    Application.ScreenUpdating = False 
    ' turns off screen updating
    Application.DisplayStatusBar = True 
    ' makes sure that the statusbar is visible
    Application.StatusBar = "Please wait while performing task 1..."
    ' add some code for task 1 that replaces the next sentence
    Application.Wait Now + TimeValue("00:00:02")
    Application.StatusBar = "Please wait while performing task 2..."
    ' add some code for task 2 that replaces the next sentence
    Application.Wait Now + TimeValue("00:00:02")
    Application.StatusBar = False 
    ' gives control of the statusbar back to the programme
End Sub

Afaik, Word & Excel이 사용하는 파란색의 도트를 재현하여 파일을 열 때 100%를 향한 진행을 보여줄 방법이 없습니다.

한 번은 상태 표시 줄에서 복제 할 코드를 본 것을 기억하지만 복잡했으며 응용 프로그램을 사용하여 상태 표시 줄에서 "x% 완료"라고 말하기에 충분할 때 권장하지 않을 것입니다.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top