Computing Staff
  • 0

VBA Excel Loop A Sound?

  • 0

I am currently using the following code to play a Wav file, but i want to make it loop.

 

Option Explicit
Private Declare Function sndPlaySound32 Lib “WINMM.DLL” _
Alias “sndPlaySoundA” (ByVal lpszSoundName _
As String, ByVal uFlags As Long) As Long

 

Sub PlaySong(ByVal Play As Boolean)
If Play = True Then
Call sndPlaySound32(“C:\Documents and Settings\Owner\Desktop\spelunk.wav”, 1)
Else
Call sndPlaySound32(“C:\Documents and Settings\Owner\Desktop\spelunk.wav”, 0)
End If
End Sub

Share

1 Answer

  1. Have you considered adding a PlayAgain: label and a GoTo PlayAgain instruction?

    Click Here Before Posting Data or VBA Code —> How To Post Data or Code.

    • 0