I'd guess you would need to do something like:
Sub macro_2()
Dim wavfil As OLEObject
Set wavfil = Sheets("Sheet1").OLEObjects(1)
wavfil.Verb Verb:=xlPrimary
End Sub
Rather than the shapes version but I think that the .verb method will select the sheet the object is on anyway if you run that code while another worksheet is selected. So you may as well just change the sheet in the code.
An alternative, if you know what the target file is, would be to just play the .wav file from vba. Something like:
Option Explicit
Public Declare Function sndPlaySound32 _
Lib "winmm.dll" _
Alias "sndPlaySoundA" ( _
ByVal lpszSoundName As String, _
ByVal uFlags As Long) As Long
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") & "\Media\" & WhatSound
If InStr(1, WhatSound, ".") = 0 Then
' if WhatSound does not have a .wav extension,
' add one.
WhatSound = WhatSound & ".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& ' Finally, play the sound.
End Sub
Bookmarks