My point was that {b]as the OP had it coded[/b] it was not possible.
Yes, it IS possible if you change the methods used, as you have done - adding the use of DoEvents, additional modules, and additional objects.
More importantly...the major change is that you have
moved the processes (the procedures actioning) from the MainForm (the OP's frmProductCost) to the
sub-form (the OP's frmProgressBar).
This is highly significant, and ties in exactly with what I was trying to say. Yes, your suggestions absolutely work (I just did them), but the reason it does is that the instructions to BE aborted have been moved.
To be more specific:
In your example, the button of the
first userform does one thing...unloads the userform.
Code:
Private Sub OKButton_Click()
Unload Me
End Sub
In the OP's userform it is THAT button (and the focus required) that does the actions.
Code:
Private Sub cmdCreate_click()
Me.Hide
'show progress bar / abort userfrom
frmProgressBar.Show
Application.ScreenUpdating = False
'create "out" folders
Call CreateFolders
'open, merge, save, close all docs
Call Proposal1
Call Proposal2
Call Proposal3
Call Proposal4
Call Proposal5
People put progress bars on the userform that is performing the actions. Which is what you have done by having those instructions on the second userform. Thus, they are in Scope. If your
actions:
Code:
For j = 1 To 10
Set TempDoc = Documents.Add(Visible:=False)
For i = -10 ^ 8 To 10 ^ 8: Next ' Artificial delay
TempDoc.Close wdDoNotSaveChanges
UF2.Label.Width = UF2.Label.Width + 20
are in the first userform (where the OP has it, or the equivalent) and THAT userform is .Hide, with the second as .Show, then the instructions will not be executed.
This is what I have repeatedly mentioned. Scope. You changed the Scope by putting the progress bar on the SAME userform as the instructions to BE aborted. Thus Abort is...in Scope, and can work. If they are not in Scope, then...they are not.
"A little piece of heaven
without that awkward dying part."
advertisment for Reese's Peanut Butter Cups (a chocolate/peanut butter confection)
Gerry