title: playing a windows media file vba a few times
body: <p>I've created a one octave piano in excel VBA.  Using the keys as images with a sub attached to each which plays a note.  I've added the capability to record your played notes using this code for each "note", optionbutton1 being the "you are now recording" selection.</p>
  
  <pre><code>Private Sub A_Click()
  WindowsMediaPlayer1.URL = "F:\New Folder\puzzles\Anote.wav"
  If OptionButton1.Value = True Then
     Dim x As String
     x = "A"
     Range("A" &amp; Rows.Count).End(xlUp).Offset(1).Select
     ActiveCell.Value = x
  End If
  End Sub
  </code></pre>
  
  <p>Where my issue comes in is playing the recording.  I need to loop through all the cells.  I'm using a For Each Loop.  The if statement will of course be expanded to encompass the entire octave.</p>
  
  <pre><code>Dim wks As Worksheet
  Set wks = ActiveSheet
  
  Dim LastRow As Long
  LastRow = wks.Cells(wks.Rows.Count, "A").End(xlUp).Row
  
  For Each cell In Worksheets("Sheet1").Range("A2:A" &amp; LastRow)
  If cell.Value = "A" Then
      WindowsMediaPlayer1.URL = "F:\New Folder\puzzles\Anote.wav"
      WindowsMediaPlayer1.controls.play 
  ElseIf cell.Value = "C" Then
      WindowsMediaPlayer1.URL = "F:\New Folder\puzzles\Cnote.wav"
      WindowsMediaPlayer1.controls.play 
  End If
  Next cell
  </code></pre>
  
  <p>To see it go through I put an action wait and it cycles through the cells just fine and when I put a code that just changes the values of the cells it does that too, but with the sounds it only plays a note once it gets to the last cell.</p>
  
  <p>I figure that I have to be be doing something wrong with the media player controls, but I can't figure out what.
  Thanks,</p>