Adding a startup sound to Application SOLVED

Thought someone might be interested as it was a long and hard search to finally get a startup sound in wma happening (mp3 file size are too large)
I wanted to make a professional app so in addition to the splash screen I added a startup sound. The wma file is obviously added at install time.

In Excel object ThisWorkbook Sub workbook_Open

I have a call to
Application.Run “startupsound”

The rest of the coding in standard modules is

Public 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 startupsound()

'This will play a start up sound saved as a companian file

Dim strFile As String
Dim strAction As String
Dim lngErr As Long

Dim XLSPadlock As Object
Set XLSPadlock = Application.COMAddIns("GXLSForm.GXLSFormula").Object
strFile = XLSPadlock.PLEvalVar("EXEPath")
strFile = strFile & "INTRO.wma"

'strFile = “G:\Dropbox\Decisive Group\Business Plan\LOGO\INTRO.wma” ’ the file you want to open/etc.
strAction = “OPEN” ’ action might be OPEN, NEW or other, depending on what you need to do

lngErr = ShellExecute(0, strAction, strFile, “”, “”, 0)

End Sub

1 Like