title: How to loop a sound
body: <p>I'm using this code to play a sound and open a userform when a command button is pressed in excel.</p>
  
  <pre><code>Private Sub CommandButton4_Click()
      Call PlayIt
      RequestAssistanceUserForm.Show
  End Sub
  
  Sub PlayTheSound(ByVal WhatSound As String)
      If Dir(WhatSound, vbNormal) = "" Then
          ' WhatSound is not a file. Get the file named by
          ' WhatSound from the Windows\Media directory.
          WhatSound = Environ("SystemRoot") &amp; "\Media\" &amp; WhatSound
          If InStr(1, WhatSound, ".") = 0 Then
              ' if WhatSound does not have a .wav extension,
              ' add one.
              WhatSound = WhatSound &amp; ".wav"
          End If
          If Dir(WhatSound, vbNormal) = vbNullString Then
              Beep            ' Can't find the file. Do a simple Beep.
              Exit Sub
  
          End If
      Else
          ' WhatSound is a file. Use it.
      End If
      sndPlaySound32 WhatSound, 0&amp;    ' Finally, play the sound.
  End Sub
  
  Sub PlayIt()
      PlayTheSound "tada.wav"
  End Sub
  </code></pre>
  
  <p>I would like the sound to loop until a button on the userform is pressed to stop it, but I'm not sure how to achieve this. If you are able to point me in the right direction (in terms of how to code this) it would be very much appreciated. Many thanks</p>