I have a workbook that opens as "Application.Visible = False." A userform opens instead. On the userform is a toggle button to hide or unhide the spreadsheet.. So far, everything works flawlessly. Toggle in, toggle out, shows or hides.
The glitch comes if the userform is closed for some reason. If that happens, there is a button on the spreadsheet to call the userform, When that is done, if the toggle button is pressed, nothing happens. It has to be pressed for a second time before it will work. After that, it again works flawlessly. It's only that first click after re-calling the form that it misbehaves.
I figure there has to be some conflict in the code that's confusing it, but I can't find what it is. The code for the toggle is as follows—
Private Sub ToggleShow_Hide_Click()
If ToggleShow_Hide.Value = False Then
Call Hide_Window
Call Show_Userform1
Else
Call Show_Window
End If
End Sub
—and the three "Calls" are these:
Option Explicit
Sub Hide_Window()
Application.Visible = False
End Sub
Sub Show_Window()
Application.Visible = True
End Sub
Sub Show_Userform1()
If UserForm1.Visible Then
Exit Sub
Else
UserForm1.Show vbModeless
End If
End Sub
Any help here? (There's more code to the Userform than this, but I can't find any that interacts with the toggle button in question. I hate to post a whole wall of text that's not needed.)
Bookmarks