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.
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.