Play .wav file when user form opens

paulralph86

New Member
Joined
Mar 28, 2017
Messages
18
Hi guys,

I have a workbook that on opening, uploads a user form login page. Following the login, the login user form closes and opens the main user form. I want to have a welcome message play once only when the main user form opens. I've tried googling various ways to do it but so far I've been unsuccessful.

The main user form name is userform_E
The sound clip file path is C:\Users\PRa\Music\welcome.wav

I'd appreciate any help you can give me.

Thanks,
Paul
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
At the top of a general Module in your VBA project put this:

Code:
Public Declare Function sndPlaySound32 Lib "winmm.dll" Alias "sndPlaySoundA" _
(ByVal lpszSoundName As String, ByVal uFlags As Long) As Long

then when you initialize/load the userform, put this line:

Code:
sndPlaySound32 "C:\Users\PRa\Music\welcome.wav", 1
 
Upvote 0

Forum statistics

Threads
1,223,904
Messages
6,175,295
Members
452,632
Latest member
jladair

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