how to display the amount of time take in status bar

V

vijaya sekhar vasa

helo,

I am trying to scan 100 word files in a folder and while scanning , I
would like to display the amount of time it is taking to scan the
whole documents,
can anyone please tell me the way to display that in a status bar.

regards
vijaya sekhar vasa
 
J

Jean-Guy Marcil

Bonjour,

Dans son message, < vijaya sekhar vasa > écrivait :
In this message, < vijaya sekhar vasa > wrote:

|| helo,
||
|| I am trying to scan 100 word files in a folder and while scanning , I
|| would like to display the amount of time it is taking to scan the
|| whole documents,
|| can anyone please tell me the way to display that in a status bar.
||

I do not know if you can run a macro and simultaneously change the StatusBar
text. I think this would require two macros to run at the same time.

What I know you can do is use a counter, and periodically change the text:
For example:
Application.StatusBar = i & " of 10 documents processed"

To see this in action, try this silly code:
'_______________________________________
Sub ChangeStatusBarText()

Dim i As Long
Dim j As Long

For i = 1 To 10
Application.StatusBar = i & " of 10 documents processed"
j = 0
Do While j < 5000000
j = j + 1
Loop
Next i

End Sub
'_______________________________________

Just declare a counter, and every time you finish a document, increase the
counter by one and change the status text. You can probably find other ways
to increase the counter, depending on what you are actually doing with your
documents.

If you really want the time elapsed, play around with something like:

'_______________________________________
Sub ChangeStatusBarText()

Dim i As Long
Dim j As Long
Dim MyTime As Single
Dim ElapsedTime As Single

MyTime = Timer
ElapsedTime = 0

For i = 1 To 20
Application.StatusBar = ElapsedTime & " seconds elapsed."
j = 0
Do While j < 5000000
j = j + 1
Loop
ElapsedTime = Format(Timer - MyTime, "0.00")
Next i

End Sub
'_______________________________________

On my machine that takes 13 seconds to run.

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 
W

Word Heretic

G'day (e-mail address removed) (vijaya sekhar vasa),

I use this stopwatch code:

Sub SomeReallyLongProcess()

Dim dim dim
Dim StartTimer as Long

StartTimer = Timer

blah blah blah - long process

StopWatch Timer,"Done the really long thingo"
End Sub



Private Sub StopWatch(ByRef StartTimer As Single, ByRef Msg As String)
'www.WordHeretic.com

Dim Hrs As Long
Dim Mins As Long
Dim Secs As Single
Dim TimeReport As String

Secs = Timer - StartTimer

Hrs = Secs \ 3600
Secs = Secs - Hrs * 3600
Mins = Secs \ 60
Secs = Int(Secs - Mins * 60 + 0.5)

If Hrs > 0 Then TimeReport = Format$(Hrs) & " hrs"
If Mins > 0 Then
If Hrs > 0 Then TimeReport = TimeReport & ", "
TimeReport = TimeReport & Format$(Mins) & " mins"
End If

If Secs > 0 And Hrs = 0 Then
If Len(TimeReport) > 0 Then TimeReport = TimeReport & ", "
TimeReport = TimeReport & Format$(Secs) & " secs"
End If

Debug.Print TimeReport & " >>> " & Msg
End Sub




Steve Hudson - Word Heretic
Want a hyperlinked index? S/W R&D? See WordHeretic.com

steve from wordheretic.com (Email replies require payment)


vijaya sekhar vasa reckoned:
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top