LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 575
Default Programming the Progress Bar problem

Jane,

two ways. You can either wrap the progress bar around the call to the macro
in the calling routine, or write the code into the macro.

e.g. PB in the calling routine as follows

Sub MainCallingRoutine
Dim PB as clsProgBar

set PB = New clsProgBar

with PB

.caption1 = "calling sub macro now"
.show
doevents

end with

Call SubRoutine

PB.Finish
Set PB = Nothing
End Sub

Sub SubRoutine
'do something here
End Sub

or the alternative approach to embed it in the macro itself

Sub SubRoutine
Dim PB as clsProgBar
Set PB = new clsProgBar
PB.Show

For nCounter = 1 to 100

'do something here
PB.Caption1 = "done " & nCounter & " iterations so far"
PB.Progress = nCounter

Next nCounter

PB.Finish
Set PB = Nothing

End Sub

The example on my site spells out that you have to include frmProgress and
clsProgBar in your project for this to work of course.

HTH,

Robin Hammond
www.enhanceddatasystems.com

"Jane" wrote in message
...
I'm a noob when it comes to programming. So please bare with me, how can I
run this code at the same time with my macro that I want run?



"Robin Hammond" wrote in message
...
Jeff,

Without knowing exactly what you are trying to do it's hard to advise,
but
I've rationalised what your code does in two different routines below.
The
first calls the Start and BringIn routines 33 times each as you do in
your
posted code, which seems odd. The second calls them once. I'm not sure

which
is appropriate. Have a look at the two examples below.

HTH

Robin Hammond
www.enhanceddatasystems.com

Sub ImportData()
'original structure which calls Start, BringInLE and BringInActuals
within
loops
Dim PB As clsProgBar
Dim nCounter As Integer

Set PB = New clsProgBar

With PB

.Title = "Importing"
.Show
.Caption1 = "Starting Import..."
DoEvents

For nCounter = 0 To 33

Call Start
.Progress = nCounter
If UserCancelled1 = True Then GoTo EndRoutine

Next nCounter

.Caption1 = "Bringing in LE..." 'whatever that is

For nCounter = 33 To 66

Call Bring_In_LE
.Progress = nCounter
If UserCancelled1 = True Then GoTo EndRoutine

Next nCounter

.Caption1 = "Bringing in Actuals"

For nCounter = 66 To 100

Call Bring_In_Actuals
.Progress = nCounter

If UserCancelled1 = True Then GoTo EndRoutine

Next nCounter

EndRoutine:

.Finish

End With

Set PB = Nothing

MsgBox "You have finished importing LE's & Actuals"
End Sub

Sub ImportData2()
'revised version, assumes you only need to call Start, etc once
Dim PB As clsProgBar
Dim nCounter As Integer

Set PB = New clsProgBar

With PB

.Title = "Importing"
.Caption1 = "Starting Import..."
.Show
DoEvents

Start
If UserCancelled1 = True Then GoTo EndRoutine
.Progress = 30

.Caption1 = "Bringing in LE..." 'whatever that is
Bring_In_LE
If UserCancelled1 = True Then GoTo EndRoutine
.Progress = 60

.Caption1 = "Bringing in Actuals"
Bring_In_Actuals

EndRoutine:

.Finish

End With

Set PB = Nothing
MsgBox "You have finished importing LE's & Actuals"
End Sub


"Jeff" wrote in message
...
I have gone to Robin's site and updated to the latest progress bar code.
However when I try to run it and my code together my code takes 100x
longer
to run. here is how I've tucked in my code.
Dim PB As clsProgBar
Dim nCounter As Integer
Dim lWaitCount As Long

Set PB = New clsProgBar

With PB
.Title = "Enhanced Datasystems Progress Bar"
.Caption2 = "This is caption 2"
.Caption3 = "This is caption 3"
.Show

For nCounter = 0 To 33
Call Start
.Progress = nCounter
.Caption1 = "Progress message " & CStr(nCounter)
For lWaitCount = 0 To 1000000
If UserCancelled1 = True Then GoTo EndRoutine
Next lWaitCount
Next nCounter

For nCounter = 33 To 66
Call Bring_In_LE
.Progress = nCounter
.Caption1 = "Progress message " & CStr(nCounter)
For lWaitCount = 0 To 1 '000000
If UserCancelled1 = True Then GoTo EndRoutine
Next lWaitCount
Next nCounter

For nCounter = 66 To 100
Call Bring_In_Actuals
.Progress = nCounter
.Caption1 = "Progress message " & CStr(nCounter)
For lWaitCount = 0 To 1 '000000
If UserCancelled1 = True Then GoTo EndRoutine
Next lWaitCount
Next nCounter
EndRoutine:

.Finish

End With

Set PB = Nothing

MsgBox "You have finished importing LE's & Actuals"
End Sub


"Robin Hammond" wrote:

Jeff,

Not sure if this will help, or how committed to you are your current
solution, but there is an alternative prog bar class on my site and

some
illustrative code on how to use it.

http://www.enhanceddatasystems.com/E...rogressBar.htm

Robin Hammond
www.enhanceddatasystems.com

"Jeff" wrote in message
...
I am using the following code to genereate messages and control the
progress
bar. My Question is, how do I fit this around my code so that the

code
I
want
to run runs, and that the progress bar is also run.


Sub ProgressBarAdvancedDemo()
Dim sb As clsProgressBar, i As Long
Set sb = New clsProgressBar
sb.Show "Please wait", "Initializing...", 0

For i = 0 To 30 Step 5
sb.PercentComplete = i
WaitSeconds 1
Next i

sb.PreMessageFG_RGB = RGB(255, 255, 255)

For i = 35 To 70 Step 5
sb.PercentComplete = i
WaitSeconds 1
Next i
sb.ProgressBarFG_RGB = RGB(255, 0, 0)
sb.PreMessage = "Still doing nothing much"

For i = 75 To 90 Step 5
sb.PercentComplete = i
WaitSeconds 1
Next i

sb.PostMessage = "Almost there!"

For i = 95 To 100 Step 5
sb.PercentComplete = i
WaitSeconds 1
Next i

Set sb = Nothing
End Sub











 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
progress bar problem still [email protected] Excel Programming 13 January 23rd 05 11:50 PM
Histogram / Count Programming Problem Jan Grinwis Excel Programming 1 October 6th 04 07:28 AM
macro programming problem Dave Murto[_2_] Excel Programming 1 January 3rd 04 02:29 AM
linerar/integer programming problem ben h Excel Programming 3 December 22nd 03 12:46 PM
Excel programming problem Peter Hansson Excel Programming 2 November 9th 03 03:19 PM


All times are GMT +1. The time now is 10:56 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"