Order of executed code; synching sounds with making shapes visible

lmoseley7

Board Regular
Joined
Jul 9, 2013
Messages
151
I was working on a presentation for work where I wanted to build a 'Family Feud' type board to play a game. In the board I am using activex text boxes with code that would hide the text box to reveal the answer underneath or it would show a custom shape (an X in a box) and play the buzzer sound. The code is pretty simple, first I would make the shape visible, then I would play the sound then the shape would be made invisible. If I step through the macro everything works fine, but when I run the macro, you never see the shape. It's almost as if the sound plays before the shape shows up and then it is made invisible again. I tried putting a wait and a sleep command between making the shape visible and playing the sound but that made no difference. If I remove the code to hide the shape at the end and run the macro, the sound plays and then the shape appears. Is there anyway to have the shape appear prior to or at the same time as the sound plays?

Here is my code:
Code:
Private Sub CommandButton8_Click()
    Application.ScreenUpdating = True
    ActiveSheet.Shapes("First Strike").Visible = True
    Play_Strike_Sound
    'The previous line refers to another macro that has the code commented below.  The sndPlaySound32
    'function is one I picked up from cpearson.com
               'sndPlaySound32 "C:\_Fin Sys\Sounds\ff-strike.wav", SND_SYNC
    ActiveSheet.Shapes("First Strike").Visible = False
End Sub
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
where did you apply the wait feature. you may need to play around with it more. have you tried adding wait before the shape.visible = false?

Code:
Application.Wait Now + TimeValue("00:00:08")

ActiveSheet.Shapes("First Strike").Visible = False
 
Upvote 0
where did you apply the wait feature. you may need to play around with it more. have you tried adding wait before the shape.visible = false?

Code:
Application.Wait Now + TimeValue("00:00:08")

ActiveSheet.Shapes("First Strike").Visible = False

I actually added it after making the shape invisible.
 
Upvote 0
Okay, so I tried moving the wait code to just before making the shape invisible, and that only keeps the shape from being visible for that amount of time and then it flashes very quickly on and off. Anyone else know how I can make the image appear before the sound or in sync with the sound?
 
Upvote 0

Forum statistics

Threads
1,216,810
Messages
6,132,832
Members
449,761
Latest member
AUSSW

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