I have pieced together a macro that will play a song according to a schedule that I have laid out. The problem that I am running into is that people are getting sick of the same song and its a pain to redefine the file destination all of the time.
I need a way to randomize the songs being selected.
In the Private module ThisWorkbook the code is:
Private Sub Workbook_Open()
Application.OnTime TimeValue("6:50:00"), "MyMacro"
Application.OnTime TimeValue("7:50:00"), "MyMacro"
Application.OnTime TimeValue("8:50:00"), "MyMacro"
Application.OnTime TimeValue("9:50:00"), "MyMacro"
Application.OnTime TimeValue("10:50:00"), "MyMacro"
Application.OnTime TimeValue("11:50:00"), "MyMacro"
Application.OnTime TimeValue("13:20:00"), "MyMacro"
Application.OnTime TimeValue("14:20:00"), "MyMacro"
Application.OnTime TimeValue("15:20:00"), "MyMacro"
Application.OnTime TimeValue("16:20:00"), "MyMacro"
Application.OnTime TimeValue("17:20:00"), "MyMacro"
Application.OnTime TimeValue("18:20:00"), "MyMacro"
Application.OnTime TimeValue("19:20:00"), "MyMacro"
Application.OnTime TimeValue("20:50:00"), "MyMacro"
Application.OnTime TimeValue("21:50:00"), "MyMacro"
Application.OnTime TimeValue("22:50:00"), "MyMacro"
End Sub
In the Standard Module the code is:
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
Sub MyMacro()
Application.OnTime TimeValue("6:50:00"), "MyMacro"
Application.OnTime TimeValue("7:50:00"), "MyMacro"
Application.OnTime TimeValue("8:50:00"), "MyMacro"
Application.OnTime TimeValue("9:50:00"), "MyMacro"
Application.OnTime TimeValue("10:50:00"), "MyMacro"
Application.OnTime TimeValue("11:50:00"), "MyMacro"
Application.OnTime TimeValue("13:20:00"), "MyMacro"
Application.OnTime TimeValue("14:20:00"), "MyMacro"
Application.OnTime TimeValue("15:20:00"), "MyMacro"
Application.OnTime TimeValue("16:20:00"), "MyMacro"
Application.OnTime TimeValue("17:20:00"), "MyMacro"
Application.OnTime TimeValue("18:20:00"), "MyMacro"
Application.OnTime TimeValue("19:20:00"), "MyMacro"
Application.OnTime TimeValue("20:50:00"), "MyMacro"
Application.OnTime TimeValue("21:50:00"), "MyMacro"
Application.OnTime TimeValue("22:50:00"), "MyMacro"
Dim handle As Long
handle = ShellExecute(0, "", "C:\Users\kwinnike\Desktop\Kalimba.mp3", 0, 0, SW_SHOWNORMAL)
End Sub
The ShellExecute is selecting a final file destination, but I would like to select final folder destination and be able to randomly select the files in the folder.
Any suggestions?
Thanks in advance for your help, its much appreciated!
I need a way to randomize the songs being selected.
In the Private module ThisWorkbook the code is:
Private Sub Workbook_Open()
Application.OnTime TimeValue("6:50:00"), "MyMacro"
Application.OnTime TimeValue("7:50:00"), "MyMacro"
Application.OnTime TimeValue("8:50:00"), "MyMacro"
Application.OnTime TimeValue("9:50:00"), "MyMacro"
Application.OnTime TimeValue("10:50:00"), "MyMacro"
Application.OnTime TimeValue("11:50:00"), "MyMacro"
Application.OnTime TimeValue("13:20:00"), "MyMacro"
Application.OnTime TimeValue("14:20:00"), "MyMacro"
Application.OnTime TimeValue("15:20:00"), "MyMacro"
Application.OnTime TimeValue("16:20:00"), "MyMacro"
Application.OnTime TimeValue("17:20:00"), "MyMacro"
Application.OnTime TimeValue("18:20:00"), "MyMacro"
Application.OnTime TimeValue("19:20:00"), "MyMacro"
Application.OnTime TimeValue("20:50:00"), "MyMacro"
Application.OnTime TimeValue("21:50:00"), "MyMacro"
Application.OnTime TimeValue("22:50:00"), "MyMacro"
End Sub
In the Standard Module the code is:
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
Sub MyMacro()
Application.OnTime TimeValue("6:50:00"), "MyMacro"
Application.OnTime TimeValue("7:50:00"), "MyMacro"
Application.OnTime TimeValue("8:50:00"), "MyMacro"
Application.OnTime TimeValue("9:50:00"), "MyMacro"
Application.OnTime TimeValue("10:50:00"), "MyMacro"
Application.OnTime TimeValue("11:50:00"), "MyMacro"
Application.OnTime TimeValue("13:20:00"), "MyMacro"
Application.OnTime TimeValue("14:20:00"), "MyMacro"
Application.OnTime TimeValue("15:20:00"), "MyMacro"
Application.OnTime TimeValue("16:20:00"), "MyMacro"
Application.OnTime TimeValue("17:20:00"), "MyMacro"
Application.OnTime TimeValue("18:20:00"), "MyMacro"
Application.OnTime TimeValue("19:20:00"), "MyMacro"
Application.OnTime TimeValue("20:50:00"), "MyMacro"
Application.OnTime TimeValue("21:50:00"), "MyMacro"
Application.OnTime TimeValue("22:50:00"), "MyMacro"
Dim handle As Long
handle = ShellExecute(0, "", "C:\Users\kwinnike\Desktop\Kalimba.mp3", 0, 0, SW_SHOWNORMAL)
End Sub
The ShellExecute is selecting a final file destination, but I would like to select final folder destination and be able to randomly select the files in the folder.
Any suggestions?
Thanks in advance for your help, its much appreciated!