PDA

View Full Version : Solved: progress bar



Djblois
12-28-2006, 09:15 AM
I am trying to use this great code from Johnske.

Option Explicit

Private Sub AddReference()
On Error Resume Next '< error = reference already set
'set reference to Microsoft Windows Common Controls 6.0 (SP4)
'(aka: Microsoft Progress Bar Control 6.0 (SP4))
ThisWorkbook.VBProject.References.AddFromGuid _
"{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}", 2, 0
End Sub

Sub ShowForm()
Call AddReference
UserForm1.Show
End Sub

'*****************************************************



'*****************************************************
'<< CODE FOR USERFORM1 CODE MODULE >>
Option Explicit

Private Sub UserForm_Activate()
Dim M&, N&
'*******PROPERTIES*******
With UserForm1
'(set form properties)
.Height = 120
.Width = 380
.Caption = "My Progress Indicators"
End With
With ProgressBar1
'(set prog.bar1 properties)
.Height = 15
.Width = 355
.Left = 10
.Top = 30
.Min = 0
.Max = 100
.Scrolling = ccScrollingSmooth
End With
With ProgressBar2
'(set prog.bar2 properties) .Height = 15 .Width = 355 .Left = 10 .Top = 75 .Min = 0 .Max = 40 .Scrolling = ccScrollingStandard End With
With Label1
'(set label1 properties)
.Height = 15
.Width = 130
.Left = 10
.Top = 15
End With
With Label2
'(set label2 properties)
.Height = 15
.Width = 130
.Left = 10
.Top = 60
End With
'************************
'*******PROGRESS********
For M = 1 To 40
For N = 1 To 100
ProgressBar1 = N
Label1 = "Individual Progress = " & N & "%"
DoEvents
Next N
ProgressBar2 = M
Label2 = "Over-all Progress = " & M * 2.5 \ 1 & "%"
DoEvents
Next M
'************************
Unload Me
End Sub

However, I am having trouble with the code in two ways. How can I get it to work with the progress of my program. And, right now it takes precedent over any other procedures, you can't minimize excel. I want the user to be able to minimize excel and then maximize it again to view the progress.

Bob Phillips
12-28-2006, 09:32 AM
Why don't you put the progress meter in the statusbar? Look here (http://j-walk.com/ss/excel/files/developer.htm)in the item called
(http://j-walk.com/ss/excel/files/developer.htm)Control the LED Display in the StatusBar

Djblois
12-28-2006, 09:35 AM
That looks like it would work better. However, how do I get to actually account for the progress of my program?

Bob Phillips
12-28-2006, 10:24 AM
That is the $60M question, and always applies. You need to understand your data and code well enough to know where you can issue a call to the progress bar. Without knowig your code, I cannot tell you where.

Djblois
12-28-2006, 11:16 AM
Thanks again firefyter, I figured it out.

Bob Phillips
12-28-2006, 12:19 PM
Thanks again firefyter, I figured it out.

:confused2

Djblois
12-28-2006, 12:22 PM
lol, sorry Xld thank you. I am losing my mind!!

Bob Phillips
12-28-2006, 01:02 PM
As long as it is not me losing mine :rotlaugh: