I have a UserForm (named "Update_Status") that I've created to display the status of a subroutine tree that's in process. (By subroutine tree, I mean that I have a series of consecutive subroutines running, not just a single subroutine. Kind of beside the point, but clarity is often a good thing! ;))
At one point in the process, I need to hide this "Update_Status" UserForm in order to manipulate the spreadsheet data through another UserForm that I've created. Basically, the Update_Status UserForm is in the way, and I need it gone in order to see the spreadsheet data that I'm manipulating. I use several of these types of UserForms in the process, so I'm very comfortable with understanding how to manipulate them, and I've been writing this type of code using UserForms for years.
However, I can't get the Update_Status UserForm to go way. Arrrggghh! (Die! Die! Die! Already!)
I've tried:
Out of crushing frustration, I even went overboard with:
Unload Update_Status
DoEvents
Unload Update_Status
DoEvents
Unload Update_Status
DoEvents
Unload Update_Status
DoEvents
Unload Update_Status
DoEvents
Unload Update_Status
DoEvents
Unload Update_Status
DoEvents
Unload Update_Status
DoEvents
Unload Update_Status
Display More
Yet, my UserForm persists. ??? Really. Come on! Just die already!
Okay, so if I step through the code, it dies fine.
Here's my actual code:
If IsWorkbookOpen(MyUpdateWorkbookName) = "No" Then
If DoesWorkbookExist(MyRealEstateDirectory() & "Database of All Properties\Download Data\" & MyCityName & "\" & MyUpdateWorkbookName) = "No" Then
'Hide the Update_Status UserForm during the following dialogs.
Unload Update_Status
DoEvents
Unload Update_Status
DoEvents
Unload Update_Status
DoEvents
Unload Update_Status
DoEvents
Unload Update_Status
DoEvents
Unload Update_Status
DoEvents
Unload Update_Status
DoEvents
Unload Update_Status
DoEvents
Unload Update_Status
DoEvents
Unload Update_Status
DoEvents
Unload Update_Status
DoEvents
Unload Update_Status
DoEvents
Unload Update_Status
DoEvents
'Determine what the user wants to do.
If MsgBox("No current update file found." & vbCrLf & vbCrLf & _
"To STOP processing, click the ""No"" button." & vbCrLf & vbCrLf & _
"To CONTINUE processing, and open a file to use as the current Update file, click the ""Yes"" button.", vbYesNo) = vbNo Then
Unload Update_Status 'Because the UserForm insists on persisting. :/
DoEvents
Exit Sub
End If
Unload Update_Status 'Because the UserForm insists on persisting. :/
RE_DU_Save_Update_File.Show 'This UserForm allows the user to open and perform manipulations to the desired Update Workbook.
If DoesWorkbookExist(MyRealEstateDirectory() & "Database of All Properties\Download Data\" & MyCityName & "\" & MyUpdateWorkbookName) = "No" Then
MsgBox "Something is wrong. Terminating Code."
VariableHolder.Label1.Caption = "Terminate"
Exit Sub
Else
Workbooks.Open (MyRealEstateDirectory() & "Database of All Properties\Download Data\" & MyCityName & "\" & MyUpdateWorkbookName)
End If
Else
Workbooks.Open (MyRealEstateDirectory() & "Database of All Properties\Download Data\" & MyCityName & "\" & MyUpdateWorkbookName)
End If
End If
Display More
Like I said, if I step-through the code, it dies fine. If I run the code, it doesn't.
If I put a breakpoint on the "If MsgBox("No current update file found." line (as shown below, designated by the asterisk (*)), and run the code, the code stops at that line, waiting for me to continue the step-through, but the Update_Status UserForm is still *expletive* displayed! (Seriously! Just DIE already!)
Unload Update_Status
DoEvents
'Determine what the user wants to do.
* If MsgBox("No current update file found." & vbCrLf & vbCrLf & _
"To STOP processing, click the ""No"" button." & vbCrLf & vbCrLf & _
"To CONTINUE processing, and open a file to use as the current Update file, click the ""Yes"" button.", vbYesNo) = vbNo Then
So it obviously has to run through the "Unload Update_Status" line to get to the breakpoint, but it's ignoring the statement, as even when the VBA stops at my breakpoint, the UserForm is still displayed!
If I manually move the Run Cursor (sorry if it's actually called something else; it's what I call it, and I've never taken the time to look it up.) three lines back to the "Unload Update_Status" line, and either run the code or step-through it, the UserForm goes away.
But the for the life of me, I can't get it to do it in realtime.
(For what it's worth: Windows 7, Excel 2010)
If there's something simple that I am just somehow overlooking, Great! Make me happy. If there's something deeper, and you can show me how to fix it, even better!
Thoughts?