Playing WAV file

agiammo

Board Regular
Joined
May 9, 2002
Messages
68
ok, I've looked at the tip files on this subject and added some code to my VBA, but I'm still getting an error message. Help!

Here is my code:

Private Declare Function PlaySound Lib "winmm.dll" _
Alias "PlaySoundA" (ByVal lpszName As String, _
ByVal hModule As Long, ByVal dwFlags As Long) As Long

Const SND_SYNC = &H0
Const SND_ASYNC = &H1
Const SND_FILENAME = &H20000

WAVFile = "J:\People\Aimee\dukes_horn - dont erase.wav"
Call PlaySound(WAVFile, 0&, SND_ASYNC Or SND_FILENAME)

MsgBox "You are done! Save now."
End Sub

I'm getting an error message that says "Compile Error: Only comments may appear after End Sub, End Function, or End Property."

Any ideas on what I have done wrong? I just want this one wav file to play when the macro is completed. The wav file is stored in a different folder out on the LAN.

Thanks! :)
 
What do you mean by placing that line at the 'top of the module'?

I also do not see anything marked Option Explicit.

Basically, I have a 421 line macro that works just fine, but I needed to add this one little /wav function to the end. So I just popped the code at the end. If there is some other 'prep work' that needs to occur, please let me know how to code that.

Thanks!
 
Upvote 0

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
The top of the module is the portion where you can't go any further up with the up arrow key..., you know, the top. That's where that function declaration should go.
 
Upvote 0
Ok! I finally got it up high enough so that it became it's own little section. It works now! THANK YOU!!!

:LOL:
 
Upvote 0

Forum statistics

Threads
1,214,606
Messages
6,120,485
Members
448,967
Latest member
visheshkotha

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