Gonzo
Gonzo

Reputation: 53

Change an image visible from False to True and back in a process in a Userform

I have a Sub that takes some time to process. I want an image that says "Please Wait" to appear on top of the form while processing and then disappear. I have tried this code but it is not working:

Private Sub UserForm_Initialize ()
Image1.visible=False
End Sub

Sub CommandButton1_Click ()
Image1.visible=True
'Here goes the process
Image1.visible=False
End Sub

Is that possible?

Upvotes: 2

Views: 2444

Answers (1)

Ota Milink
Ota Milink

Reputation: 38

Add DoEvents to enable VBA to process the re-paint event

Sub CommandButton1_Click ()
  Image1.visible=True
  DoEvents
  'Here goes the process
  Image1.visible=False
End Sub

Upvotes: 1

Related Questions