Time delayed self-disappearing Shape

kabanero

New Member
Joined
Dec 2, 2018
Messages
8
Hello, VBA Nation. I am using Excel for Mac 2016. I would like a Shape to popup and disappear in a few seconds after a macro is finished. It works in Step Into mode, but does not when is attached to a button or ran from VBA Editor.The Shape does not want to appear. I will appreciate any input.

Sub PopupAndGo()
' Popup is a Shape with a text
With ActiveSheet
.Shapes("Popup").Visible = msoCTrue
Application.Wait Now + TimeSerial(0, 0, 5)
.Shapes("Popup").Visible = msoFalse
End With
End Sub
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
Hi
Welcome to the board

Try:

Code:
Sub PopupAndGo()
' Popup is a Shape with a text
With ActiveSheet
    .Shapes("Popup").Visible = msoCTrue
    Application.ScreenUpdating = True ' refreshes the screen
    Application.Wait Now + TimeSerial(0, 0, 5)
    .Shapes("Popup").Visible = msoFalse
End With
End Sub
 
Last edited:
Upvote 0
The solution I posted was just to make yours work.

I would not do it like that. While the Wait is executing you can do nothing else.
I would instead lauch a timer. This way, during the 5 seconds I could be doing something else in excel.

For ex.:

Code:
Sub PopupAndGo()
' Popup is a Shape with a text
Worksheets("Sheet1").Shapes("Popup").Visible = msoCTrue
Application.OnTime Now + TimeSerial(0, 0, 5), "ShapeVisible"
End Sub

Sub ShapeVisible()
Worksheets("Sheet1").Shapes("Popup").Visible = msoFalse
End Sub
 
Upvote 0
This works!
Thanks a lot. I had been itching about this little code.
One more question if I could:
I did not disable ScreenUpdating. Why Excel did not do it on its own?
Google gives only problems re: this, but it seems its the way Excel works.
When I should insert ScreenUpdating in case I did not disable it?
Thank you very much again.
 
Upvote 0
Like I said in my second post, you cannot do anything in excel while the Wait executes.
Excel does not even run the internal refresh screen code.
When the Wait ends you immediately set the visible to false, so you never see the shape visible.
The Application.ScreenUpdating = True, in this case, is just to force the refresh on the screen before starting the Wait.

Like I said in my second post, this is not a good solution

The solution in my second post is better. You launch a timer and you can continue to work on excel during those 5 seconds.
 
Upvote 0

Forum statistics

Threads
1,214,561
Messages
6,120,225
Members
448,951
Latest member
jennlynn

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top