Ok, I have worked out something. The userform is as below (all controls have default names).
The userform module code:
VBA Code:
Option Explicit
Private Sub ComboBox1_Change()
Image1.BackColor = 1000000 * ComboBox1.ListIndex
Image1.Visible = True
ComboBox1.Enabled = False
CommandButton1.Visible = False
Application.OnTime Now + TimeValue("00:00:05"), "Module1.test_timer"
End Sub
Private Sub CommandButton1_Click()
Image1.Visible = False
CommandButton1.Visible = False
End Sub
Private Sub UserForm_Initialize()
Me.Top = Application.Top + 150
Me.Left = Application.Left + 30
ComboBox1.AddItem "test1"
ComboBox1.AddItem "test2"
ComboBox1.AddItem "test3"
CommandButton1.Visible = False
Image1.Visible = False
End Sub
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
If Not CommandButton1.Visible Then Cancel = True
End Sub
And since we can't app.ontime to a sub on a userform module, insert a new module or use an existing one (in this case Module1), the code that will make commandbutton visible.
VBA Code:
Option Explicit
Option Private Module
Public Sub test_timer()
'DoEvents
UserForm1.CommandButton1.Visible = True
UserForm1.ComboBox1.Enabled = True
End Sub
Notes:
Since changing combobox while still waiting for the test_timer sub would mess things up, I disable it until 5 seconds pass, and enable it again inside test_timer.
Userform will not close until 5 seconds pass and commandbutton appear in order to not mess anything up. This is done in QueryClose event of userform.
Me.Top and Me.Left are for convenience so userform always opens inside worksheet area regardless of which display excel window is on. If you want something similar, set userform's StartUpPosition to 0-Manual in VBA Editor properties pane. Otherwise delete those lines.
DoEvents was not necessary (at least in my test case), so I commented it out.
I just changed Image1.BackColor instead of attaching pictures as a means of testing.
In the Module1 code at the top, Option Private Module means, public subs in that module will not show when you open Macros window (ALT + F8) but you can still call them like "Call Module1.sub_name".