Turn off Popup

Photomofo

Active Member
Joined
Aug 20, 2012
Messages
259
I'm trying to have a macro play a song but I keep getting a Popup that asks me to press OK before the song starts. Any advice?

VBA Code:
Sub Play_Song()

Dim Song As String

Song = "C:\Users\Photomofo\Desktop\Music\" & Sheets("Timer").Range("B11")

Application.EnableEvents = False
Application.DisplayAlerts = False

ActiveWorkbook.FollowHyperlink Address:=Song

Application.DisplayAlerts = True
Application.EnableEvents = True

End Sub
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
Well... I solved the popup button with some different code. Anybody know how to tell Windows Media Player to stop playing with VBA?

VBA Code:
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Private Const SW_SHOWMAXIMIZED As Long = 3
Private Const SW_SHOWNORMAL As Long = 1

Sub Play_Song()

    Call PlayMusic("C:\Users\Photomofo\Desktop\Music\" & Sheets("Timer").Range("B11"))

End Sub

Sub Stop_Song()

Dim ARG As String

ARG = "C:\Users\Photomofo\Desktop\Music\" & Sheets("Timer").Range("B11")


End Sub

Sub PlayMusic(strfile As String)

    If ShellExecute(0&, "Play", strfile, 0&, 0&, SW_SHOWNORMAL) < 33 Then
        
        MsgBox "Something Went Wrong", vbInformation
    
    End If

End Sub
 
Upvote 0
Check if the following works for you

VBA Code:
Private Declare Function mciExecute Lib "winmm.dll" (ByVal Comando As String) As Long

Private Sub playsong()
  mciExecute "play " & "C:\Users\Photomofo\Desktop\Music\" & Sheets("Timer").Range("B11").value
End Sub

Private Sub stopsong()
  mciExecute "stop " & "C:\Users\Photomofo\Desktop\Music\" & Sheets("Timer").Range("B11").value
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,821
Messages
6,121,759
Members
449,048
Latest member
excelknuckles

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