Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
ATT: Chip Please help with progress reporter
Hi Chip,
I am using your progress reporter dll and it works very nicely. Unfortunately, I am too stupid to write the code to enable the user to cancel the loop by clicking on the dialog's cancel button. Can you give me some guidance please? FD |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Chip Please help with progress reporter
FD,
As far as I can see, you don't need to do anything. The DLL handles cancels quite nicely itself, all you need to do is to click the button. If you mean that you want to interrupt the Cancel event and do some of your own processing, then you need to create a class to catch the events. The class code would look something like this Option Explicit Public WithEvents PB As ProgressReporter.Progressor Public Sub PB_UserCancel(Cancel As Boolean) MsgBox "Interrupted" End Sub and using Chip's example you would invoke it like this, assuming the class module is named clsEventSink, Option Explicit Dim Prog As ProgressReporter.Progressor Dim cPB As clsEventSink Sub Test() Dim N As Long Set Prog = New ProgressReporter.Progressor Set cPB = New clsEventSink Set cPB.PB = Prog With Prog .MinimumValue = 0 .MaximumValue = 10000 .SetParentWindow 0 .CurrentValue = 0 .Show For N = 1 To 10000 ' ' your code here ' DoEvents .Increment 1 Next N End With Set cPB = Nothing Set Prog = Nothing End Sub -- HTH RP (remove nothere from the email address if mailing direct) "FrigidDigit" wrote in message ... Hi Chip, I am using your progress reporter dll and it works very nicely. Unfortunately, I am too stupid to write the code to enable the user to cancel the loop by clicking on the dialog's cancel button. Can you give me some guidance please? FD |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Chip Please help with progress reporter
Hey thanks for the response Bob!
Much appreciated! FD "Bob Phillips" wrote in message ... FD, As far as I can see, you don't need to do anything. The DLL handles cancels quite nicely itself, all you need to do is to click the button. If you mean that you want to interrupt the Cancel event and do some of your own processing, then you need to create a class to catch the events. The class code would look something like this Option Explicit Public WithEvents PB As ProgressReporter.Progressor Public Sub PB_UserCancel(Cancel As Boolean) MsgBox "Interrupted" End Sub and using Chip's example you would invoke it like this, assuming the class module is named clsEventSink, Option Explicit Dim Prog As ProgressReporter.Progressor Dim cPB As clsEventSink Sub Test() Dim N As Long Set Prog = New ProgressReporter.Progressor Set cPB = New clsEventSink Set cPB.PB = Prog With Prog .MinimumValue = 0 .MaximumValue = 10000 .SetParentWindow 0 .CurrentValue = 0 .Show For N = 1 To 10000 ' ' your code here ' DoEvents .Increment 1 Next N End With Set cPB = Nothing Set Prog = Nothing End Sub -- HTH RP (remove nothere from the email address if mailing direct) "FrigidDigit" wrote in message ... Hi Chip, I am using your progress reporter dll and it works very nicely. Unfortunately, I am too stupid to write the code to enable the user to cancel the loop by clicking on the dialog's cancel button. Can you give me some guidance please? FD |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Chip Please help with progress reporter
Bob,
Just a question. Once my procedure starts running, the dialog box does not have focus and trying to click on the cancel button has no effect. What am I doing wrong? Please let me know which code snippets you need to see to help. Thank you very much! FD "Bob Phillips" wrote in message ... FD, As far as I can see, you don't need to do anything. The DLL handles cancels quite nicely itself, all you need to do is to click the button. If you mean that you want to interrupt the Cancel event and do some of your own processing, then you need to create a class to catch the events. The class code would look something like this Option Explicit Public WithEvents PB As ProgressReporter.Progressor Public Sub PB_UserCancel(Cancel As Boolean) MsgBox "Interrupted" End Sub and using Chip's example you would invoke it like this, assuming the class module is named clsEventSink, Option Explicit Dim Prog As ProgressReporter.Progressor Dim cPB As clsEventSink Sub Test() Dim N As Long Set Prog = New ProgressReporter.Progressor Set cPB = New clsEventSink Set cPB.PB = Prog With Prog .MinimumValue = 0 .MaximumValue = 10000 .SetParentWindow 0 .CurrentValue = 0 .Show For N = 1 To 10000 ' ' your code here ' DoEvents .Increment 1 Next N End With Set cPB = Nothing Set Prog = Nothing End Sub -- HTH RP (remove nothere from the email address if mailing direct) "FrigidDigit" wrote in message ... Hi Chip, I am using your progress reporter dll and it works very nicely. Unfortunately, I am too stupid to write the code to enable the user to cancel the loop by clicking on the dialog's cancel button. Can you give me some guidance please? FD |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Chip Please help with progress reporter
Where are you placing the code? You need to declare the object
WithEvents in a class module (e.g., a regular class module, a sheet module, a userform, or the ThisWorkbook module). It won't work if you declare the object in a regular module, since regular code modules can't trap events. -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "FrigidDigit" wrote in message ... Bob, Just a question. Once my procedure starts running, the dialog box does not have focus and trying to click on the cancel button has no effect. What am I doing wrong? Please let me know which code snippets you need to see to help. Thank you very much! FD "Bob Phillips" wrote in message ... FD, As far as I can see, you don't need to do anything. The DLL handles cancels quite nicely itself, all you need to do is to click the button. If you mean that you want to interrupt the Cancel event and do some of your own processing, then you need to create a class to catch the events. The class code would look something like this Option Explicit Public WithEvents PB As ProgressReporter.Progressor Public Sub PB_UserCancel(Cancel As Boolean) MsgBox "Interrupted" End Sub and using Chip's example you would invoke it like this, assuming the class module is named clsEventSink, Option Explicit Dim Prog As ProgressReporter.Progressor Dim cPB As clsEventSink Sub Test() Dim N As Long Set Prog = New ProgressReporter.Progressor Set cPB = New clsEventSink Set cPB.PB = Prog With Prog .MinimumValue = 0 .MaximumValue = 10000 .SetParentWindow 0 .CurrentValue = 0 .Show For N = 1 To 10000 ' ' your code here ' DoEvents .Increment 1 Next N End With Set cPB = Nothing Set Prog = Nothing End Sub -- HTH RP (remove nothere from the email address if mailing direct) "FrigidDigit" wrote in message ... Hi Chip, I am using your progress reporter dll and it works very nicely. Unfortunately, I am too stupid to write the code to enable the user to cancel the loop by clicking on the dialog's cancel button. Can you give me some guidance please? FD |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
Chip Please help with progress reporter
Hi Chip!
As mentioned previously I am pretty stupid around VBA so please bear with me. I have not declared any WithEvents object as I don't have a clue how to do this. I may may be stuffing about with something I know dangerously little about but I would really like to do this right. I have perused the online help and gleaned the following: I need to create a class module containing: Public WithEvents Prog As Application Then I need to connect the declared object with the class module, right? Dim Prog As New EventClassModule Sub InitializeApp() Set Prog.App = Application End Sub Is this right? And where to from here? Thanks for your response Chip! FD "Chip Pearson" wrote in message ... Where are you placing the code? You need to declare the object WithEvents in a class module (e.g., a regular class module, a sheet module, a userform, or the ThisWorkbook module). It won't work if you declare the object in a regular module, since regular code modules can't trap events. -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "FrigidDigit" wrote in message ... Bob, Just a question. Once my procedure starts running, the dialog box does not have focus and trying to click on the cancel button has no effect. What am I doing wrong? Please let me know which code snippets you need to see to help. Thank you very much! FD "Bob Phillips" wrote in message ... FD, As far as I can see, you don't need to do anything. The DLL handles cancels quite nicely itself, all you need to do is to click the button. If you mean that you want to interrupt the Cancel event and do some of your own processing, then you need to create a class to catch the events. The class code would look something like this Option Explicit Public WithEvents PB As ProgressReporter.Progressor Public Sub PB_UserCancel(Cancel As Boolean) MsgBox "Interrupted" End Sub and using Chip's example you would invoke it like this, assuming the class module is named clsEventSink, Option Explicit Dim Prog As ProgressReporter.Progressor Dim cPB As clsEventSink Sub Test() Dim N As Long Set Prog = New ProgressReporter.Progressor Set cPB = New clsEventSink Set cPB.PB = Prog With Prog .MinimumValue = 0 .MaximumValue = 10000 .SetParentWindow 0 .CurrentValue = 0 .Show For N = 1 To 10000 ' ' your code here ' DoEvents .Increment 1 Next N End With Set cPB = Nothing Set Prog = Nothing End Sub -- HTH RP (remove nothere from the email address if mailing direct) "FrigidDigit" wrote in message ... Hi Chip, I am using your progress reporter dll and it works very nicely. Unfortunately, I am too stupid to write the code to enable the user to cancel the loop by clicking on the dialog's cancel button. Can you give me some guidance please? FD |
#7
Posted to microsoft.public.excel.programming
|
|||
|
|||
Chip Please help with progress reporter
FD,
The code I posted showed all the code, apart from your specific event code, that needs to go into the class module, and the code to add to your calling module to connect the class module to the progressbar. That was done in this snippet Dim Prog As ProgressReporter.Progressor Dim cPB As clsEventSink Sub Test() Dim N As Long Set Prog = New ProgressReporter.Progressor Set cPB = New clsEventSink Set cPB.PB = Prog You must have some code similar to that already that dimensions a progressbar variable and News it, so just add a Eventsink variable, and new that in the code, and connect with Set cPB.PB = Prog where cPB is the name of the class module, and PB is the WithEvents variable declared in the class module. -- HTH RP (remove nothere from the email address if mailing direct) "FrigidDigit" wrote in message ... Hi Chip! As mentioned previously I am pretty stupid around VBA so please bear with me. I have not declared any WithEvents object as I don't have a clue how to do this. I may may be stuffing about with something I know dangerously little about but I would really like to do this right. I have perused the online help and gleaned the following: I need to create a class module containing: Public WithEvents Prog As Application Then I need to connect the declared object with the class module, right? Dim Prog As New EventClassModule Sub InitializeApp() Set Prog.App = Application End Sub Is this right? And where to from here? Thanks for your response Chip! FD "Chip Pearson" wrote in message ... Where are you placing the code? You need to declare the object WithEvents in a class module (e.g., a regular class module, a sheet module, a userform, or the ThisWorkbook module). It won't work if you declare the object in a regular module, since regular code modules can't trap events. -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "FrigidDigit" wrote in message ... Bob, Just a question. Once my procedure starts running, the dialog box does not have focus and trying to click on the cancel button has no effect. What am I doing wrong? Please let me know which code snippets you need to see to help. Thank you very much! FD "Bob Phillips" wrote in message ... FD, As far as I can see, you don't need to do anything. The DLL handles cancels quite nicely itself, all you need to do is to click the button. If you mean that you want to interrupt the Cancel event and do some of your own processing, then you need to create a class to catch the events. The class code would look something like this Option Explicit Public WithEvents PB As ProgressReporter.Progressor Public Sub PB_UserCancel(Cancel As Boolean) MsgBox "Interrupted" End Sub and using Chip's example you would invoke it like this, assuming the class module is named clsEventSink, Option Explicit Dim Prog As ProgressReporter.Progressor Dim cPB As clsEventSink Sub Test() Dim N As Long Set Prog = New ProgressReporter.Progressor Set cPB = New clsEventSink Set cPB.PB = Prog With Prog .MinimumValue = 0 .MaximumValue = 10000 .SetParentWindow 0 .CurrentValue = 0 .Show For N = 1 To 10000 ' ' your code here ' DoEvents .Increment 1 Next N End With Set cPB = Nothing Set Prog = Nothing End Sub -- HTH RP (remove nothere from the email address if mailing direct) "FrigidDigit" wrote in message ... Hi Chip, I am using your progress reporter dll and it works very nicely. Unfortunately, I am too stupid to write the code to enable the user to cancel the loop by clicking on the dialog's cancel button. Can you give me some guidance please? FD |
#8
Posted to microsoft.public.excel.programming
|
|||
|
|||
Chip Please help with progress reporter
Thanks Bob,
Sorry about that, I was getting lost. I should have made sure I understand your code properly before asking again. Thank for your help. FD "Bob Phillips" wrote in message ... FD, The code I posted showed all the code, apart from your specific event code, that needs to go into the class module, and the code to add to your calling module to connect the class module to the progressbar. That was done in this snippet Dim Prog As ProgressReporter.Progressor Dim cPB As clsEventSink Sub Test() Dim N As Long Set Prog = New ProgressReporter.Progressor Set cPB = New clsEventSink Set cPB.PB = Prog You must have some code similar to that already that dimensions a progressbar variable and News it, so just add a Eventsink variable, and new that in the code, and connect with Set cPB.PB = Prog where cPB is the name of the class module, and PB is the WithEvents variable declared in the class module. -- HTH RP (remove nothere from the email address if mailing direct) "FrigidDigit" wrote in message ... Hi Chip! As mentioned previously I am pretty stupid around VBA so please bear with me. I have not declared any WithEvents object as I don't have a clue how to do this. I may may be stuffing about with something I know dangerously little about but I would really like to do this right. I have perused the online help and gleaned the following: I need to create a class module containing: Public WithEvents Prog As Application Then I need to connect the declared object with the class module, right? Dim Prog As New EventClassModule Sub InitializeApp() Set Prog.App = Application End Sub Is this right? And where to from here? Thanks for your response Chip! FD "Chip Pearson" wrote in message ... Where are you placing the code? You need to declare the object WithEvents in a class module (e.g., a regular class module, a sheet module, a userform, or the ThisWorkbook module). It won't work if you declare the object in a regular module, since regular code modules can't trap events. -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "FrigidDigit" wrote in message ... Bob, Just a question. Once my procedure starts running, the dialog box does not have focus and trying to click on the cancel button has no effect. What am I doing wrong? Please let me know which code snippets you need to see to help. Thank you very much! FD "Bob Phillips" wrote in message ... FD, As far as I can see, you don't need to do anything. The DLL handles cancels quite nicely itself, all you need to do is to click the button. If you mean that you want to interrupt the Cancel event and do some of your own processing, then you need to create a class to catch the events. The class code would look something like this Option Explicit Public WithEvents PB As ProgressReporter.Progressor Public Sub PB_UserCancel(Cancel As Boolean) MsgBox "Interrupted" End Sub and using Chip's example you would invoke it like this, assuming the class module is named clsEventSink, Option Explicit Dim Prog As ProgressReporter.Progressor Dim cPB As clsEventSink Sub Test() Dim N As Long Set Prog = New ProgressReporter.Progressor Set cPB = New clsEventSink Set cPB.PB = Prog With Prog .MinimumValue = 0 .MaximumValue = 10000 .SetParentWindow 0 .CurrentValue = 0 .Show For N = 1 To 10000 ' ' your code here ' DoEvents .Increment 1 Next N End With Set cPB = Nothing Set Prog = Nothing End Sub -- HTH RP (remove nothere from the email address if mailing direct) "FrigidDigit" wrote in message ... Hi Chip, I am using your progress reporter dll and it works very nicely. Unfortunately, I am too stupid to write the code to enable the user to cancel the loop by clicking on the dialog's cancel button. Can you give me some guidance please? FD |
#9
Posted to microsoft.public.excel.programming
|
|||
|
|||
Chip Please help with progress reporter
No problem, have you got it working now?
Bob "FrigidDigit" wrote in message ... Thanks Bob, Sorry about that, I was getting lost. I should have made sure I understand your code properly before asking again. Thank for your help. FD "Bob Phillips" wrote in message ... FD, The code I posted showed all the code, apart from your specific event code, that needs to go into the class module, and the code to add to your calling module to connect the class module to the progressbar. That was done in this snippet Dim Prog As ProgressReporter.Progressor Dim cPB As clsEventSink Sub Test() Dim N As Long Set Prog = New ProgressReporter.Progressor Set cPB = New clsEventSink Set cPB.PB = Prog You must have some code similar to that already that dimensions a progressbar variable and News it, so just add a Eventsink variable, and new that in the code, and connect with Set cPB.PB = Prog where cPB is the name of the class module, and PB is the WithEvents variable declared in the class module. -- HTH RP (remove nothere from the email address if mailing direct) "FrigidDigit" wrote in message ... Hi Chip! As mentioned previously I am pretty stupid around VBA so please bear with me. I have not declared any WithEvents object as I don't have a clue how to do this. I may may be stuffing about with something I know dangerously little about but I would really like to do this right. I have perused the online help and gleaned the following: I need to create a class module containing: Public WithEvents Prog As Application Then I need to connect the declared object with the class module, right? Dim Prog As New EventClassModule Sub InitializeApp() Set Prog.App = Application End Sub Is this right? And where to from here? Thanks for your response Chip! FD "Chip Pearson" wrote in message ... Where are you placing the code? You need to declare the object WithEvents in a class module (e.g., a regular class module, a sheet module, a userform, or the ThisWorkbook module). It won't work if you declare the object in a regular module, since regular code modules can't trap events. -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "FrigidDigit" wrote in message ... Bob, Just a question. Once my procedure starts running, the dialog box does not have focus and trying to click on the cancel button has no effect. What am I doing wrong? Please let me know which code snippets you need to see to help. Thank you very much! FD "Bob Phillips" wrote in message ... FD, As far as I can see, you don't need to do anything. The DLL handles cancels quite nicely itself, all you need to do is to click the button. If you mean that you want to interrupt the Cancel event and do some of your own processing, then you need to create a class to catch the events. The class code would look something like this Option Explicit Public WithEvents PB As ProgressReporter.Progressor Public Sub PB_UserCancel(Cancel As Boolean) MsgBox "Interrupted" End Sub and using Chip's example you would invoke it like this, assuming the class module is named clsEventSink, Option Explicit Dim Prog As ProgressReporter.Progressor Dim cPB As clsEventSink Sub Test() Dim N As Long Set Prog = New ProgressReporter.Progressor Set cPB = New clsEventSink Set cPB.PB = Prog With Prog .MinimumValue = 0 .MaximumValue = 10000 .SetParentWindow 0 .CurrentValue = 0 .Show For N = 1 To 10000 ' ' your code here ' DoEvents .Increment 1 Next N End With Set cPB = Nothing Set Prog = Nothing End Sub -- HTH RP (remove nothere from the email address if mailing direct) "FrigidDigit" wrote in message ... Hi Chip, I am using your progress reporter dll and it works very nicely. Unfortunately, I am too stupid to write the code to enable the user to cancel the loop by clicking on the dialog's cancel button. Can you give me some guidance please? FD |
#10
Posted to microsoft.public.excel.programming
|
|||
|
|||
Chip Please help with progress reporter
Bob,
Was hijacked by my boss to deal with another deadline, will work on it tonight and get back to you tomorrow. Thanks again, I really appreciate the time you took to help. FD "Bob Phillips" wrote in message ... No problem, have you got it working now? Bob "FrigidDigit" wrote in message ... Thanks Bob, Sorry about that, I was getting lost. I should have made sure I understand your code properly before asking again. Thank for your help. FD "Bob Phillips" wrote in message ... FD, The code I posted showed all the code, apart from your specific event code, that needs to go into the class module, and the code to add to your calling module to connect the class module to the progressbar. That was done in this snippet Dim Prog As ProgressReporter.Progressor Dim cPB As clsEventSink Sub Test() Dim N As Long Set Prog = New ProgressReporter.Progressor Set cPB = New clsEventSink Set cPB.PB = Prog You must have some code similar to that already that dimensions a progressbar variable and News it, so just add a Eventsink variable, and new that in the code, and connect with Set cPB.PB = Prog where cPB is the name of the class module, and PB is the WithEvents variable declared in the class module. -- HTH RP (remove nothere from the email address if mailing direct) "FrigidDigit" wrote in message ... Hi Chip! As mentioned previously I am pretty stupid around VBA so please bear with me. I have not declared any WithEvents object as I don't have a clue how to do this. I may may be stuffing about with something I know dangerously little about but I would really like to do this right. I have perused the online help and gleaned the following: I need to create a class module containing: Public WithEvents Prog As Application Then I need to connect the declared object with the class module, right? Dim Prog As New EventClassModule Sub InitializeApp() Set Prog.App = Application End Sub Is this right? And where to from here? Thanks for your response Chip! FD "Chip Pearson" wrote in message ... Where are you placing the code? You need to declare the object WithEvents in a class module (e.g., a regular class module, a sheet module, a userform, or the ThisWorkbook module). It won't work if you declare the object in a regular module, since regular code modules can't trap events. -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "FrigidDigit" wrote in message ... Bob, Just a question. Once my procedure starts running, the dialog box does not have focus and trying to click on the cancel button has no effect. What am I doing wrong? Please let me know which code snippets you need to see to help. Thank you very much! FD "Bob Phillips" wrote in message ... FD, As far as I can see, you don't need to do anything. The DLL handles cancels quite nicely itself, all you need to do is to click the button. If you mean that you want to interrupt the Cancel event and do some of your own processing, then you need to create a class to catch the events. The class code would look something like this Option Explicit Public WithEvents PB As ProgressReporter.Progressor Public Sub PB_UserCancel(Cancel As Boolean) MsgBox "Interrupted" End Sub and using Chip's example you would invoke it like this, assuming the class module is named clsEventSink, Option Explicit Dim Prog As ProgressReporter.Progressor Dim cPB As clsEventSink Sub Test() Dim N As Long Set Prog = New ProgressReporter.Progressor Set cPB = New clsEventSink Set cPB.PB = Prog With Prog .MinimumValue = 0 .MaximumValue = 10000 .SetParentWindow 0 .CurrentValue = 0 .Show For N = 1 To 10000 ' ' your code here ' DoEvents .Increment 1 Next N End With Set cPB = Nothing Set Prog = Nothing End Sub -- HTH RP (remove nothere from the email address if mailing direct) "FrigidDigit" wrote in message ... Hi Chip, I am using your progress reporter dll and it works very nicely. Unfortunately, I am too stupid to write the code to enable the user to cancel the loop by clicking on the dialog's cancel button. Can you give me some guidance please? FD |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Is anyone on here with DVS Reporter??? | Excel Discussion (Misc queries) | |||
Is anyone on here with DVS Reporter??? | Excel Worksheet Functions | |||
Distribution of reporter cells according to a specified column | Excel Worksheet Functions | |||
John, Bob, Chip... | Excel Programming | |||
Chip, I solved it | Excel Programming |