Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 78
Default play sound when opening workbook

I want when I open my workbook to automatically start sound. I have one
waw file in C:\musik\test.waw.
How can i do that?

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default play sound when opening workbook

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


Private Sub Workbook_Open()
PlayWavFile "C:\Windows\Media\Microsoft Office 2000\Chimes.wav"
End Sub

Public Function PlayWavFile(WavFile As String) As String
Const SND_ASYNC = &H1
Const SND_FILENAME = &H20000
PlaySound WavFile, 0, SND_ASYNC Or SND_FILENAME
PlayWavFile = ""
End Function


'This is workbook event code.
'To input this code, right click on the Excel icon on the worksheet
'(or next to the File menu if you maximise your workbooks),
'select View Code from the menu, and paste the code



--

HTH

RP
(remove nothere from the email address if mailing direct)


"Alen32" wrote in message
lkaboutsoftware.com...
I want when I open my workbook to automatically start sound. I have one
waw file in C:\musik\test.waw.
How can i do that?



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 983
Default play sound when opening workbook

Any reason you implement PlayWavFile as a function returning and empty string
instead of as a sub? Just curious... Nice code... makes me wish I had sound
here at work...

"Bob Phillips" wrote:

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


Private Sub Workbook_Open()
PlayWavFile "C:\Windows\Media\Microsoft Office 2000\Chimes.wav"
End Sub

Public Function PlayWavFile(WavFile As String) As String
Const SND_ASYNC = &H1
Const SND_FILENAME = &H20000
PlaySound WavFile, 0, SND_ASYNC Or SND_FILENAME
PlayWavFile = ""
End Function


'This is workbook event code.
'To input this code, right click on the Excel icon on the worksheet
'(or next to the File menu if you maximise your workbooks),
'select View Code from the menu, and paste the code



--

HTH

RP
(remove nothere from the email address if mailing direct)


"Alen32" wrote in message
lkaboutsoftware.com...
I want when I open my workbook to automatically start sound. I have one
waw file in C:\musik\test.waw.
How can i do that?




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default play sound when opening workbook

Hi Jim,

The reason is because I adapted a piece of code in my library. In there, it
is being used as a worksheet function, hence a function.

I also tend to write more of my procedures as functions than most, just a
style thing I guess. I read something once by Paul Lomax where he advocated
only ever using functions, which I agree with in concept, even if not in
practice, so as to test for success.

Regards

Bob

"Jim Thomlinson" wrote in message
...
Any reason you implement PlayWavFile as a function returning and empty

string
instead of as a sub? Just curious... Nice code... makes me wish I had

sound
here at work...

"Bob Phillips" wrote:

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


Private Sub Workbook_Open()
PlayWavFile "C:\Windows\Media\Microsoft Office 2000\Chimes.wav"
End Sub

Public Function PlayWavFile(WavFile As String) As String
Const SND_ASYNC = &H1
Const SND_FILENAME = &H20000
PlaySound WavFile, 0, SND_ASYNC Or SND_FILENAME
PlayWavFile = ""
End Function


'This is workbook event code.
'To input this code, right click on the Excel icon on the worksheet
'(or next to the File menu if you maximise your workbooks),
'select View Code from the menu, and paste the code



--

HTH

RP
(remove nothere from the email address if mailing direct)


"Alen32" wrote in message
lkaboutsoftware.com...
I want when I open my workbook to automatically start sound. I have

one
waw file in C:\musik\test.waw.
How can i do that?






  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 983
Default play sound when opening workbook

Works by me... Gives everything kind of a C/C++ feeling where subs just don't
exist... And heck this way you can access it from a spreadsheet and make
spreadsheets that annoy people every time they calculate... never
underestimate the fun you can have there... ;-)

"Bob Phillips" wrote:

Hi Jim,

The reason is because I adapted a piece of code in my library. In there, it
is being used as a worksheet function, hence a function.

I also tend to write more of my procedures as functions than most, just a
style thing I guess. I read something once by Paul Lomax where he advocated
only ever using functions, which I agree with in concept, even if not in
practice, so as to test for success.

Regards

Bob

"Jim Thomlinson" wrote in message
...
Any reason you implement PlayWavFile as a function returning and empty

string
instead of as a sub? Just curious... Nice code... makes me wish I had

sound
here at work...

"Bob Phillips" wrote:

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


Private Sub Workbook_Open()
PlayWavFile "C:\Windows\Media\Microsoft Office 2000\Chimes.wav"
End Sub

Public Function PlayWavFile(WavFile As String) As String
Const SND_ASYNC = &H1
Const SND_FILENAME = &H20000
PlaySound WavFile, 0, SND_ASYNC Or SND_FILENAME
PlayWavFile = ""
End Function


'This is workbook event code.
'To input this code, right click on the Excel icon on the worksheet
'(or next to the File menu if you maximise your workbooks),
'select View Code from the menu, and paste the code



--

HTH

RP
(remove nothere from the email address if mailing direct)


"Alen32" wrote in message
lkaboutsoftware.com...
I want when I open my workbook to automatically start sound. I have

one
waw file in C:\musik\test.waw.
How can i do that?







Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Play sound aac Excel Discussion (Misc queries) 2 December 5th 07 11:24 PM
Play Sound File Once when cell value condition id met John 1 Excel Discussion (Misc queries) 4 September 1st 07 04:32 PM
play sound when pressing commandbutton Hoyos Excel Discussion (Misc queries) 1 August 19th 07 04:12 PM
HOW TO PLAY SOUND.WAV FILES SIMULTANEOUSLY UNDER EXCEL Hotbird[_4_] Excel Programming 3 January 28th 05 03:16 PM
Using Countdown in Status Bar to Play Sound Full Monty Excel Programming 5 February 6th 04 05:37 PM


All times are GMT +1. The time now is 09:23 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"