Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
SteBar
 
Posts: n/a
Default Music file associated with an Excel file.

Is it possible that when I open up a particular Excel file a particular
wav/midi/mp3 music file will automatically start playing? If so, how do I
do it?

Thanks - Steve B.


  #2   Report Post  
Bob Phillips
 
Posts: n/a
Default

Steve,

Put this code in a normal code module

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


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


and then in ThisWorkbook add this code



Private Sub Workbook_Open()

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

HTH

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


"SteBar" wrote in message
...
Is it possible that when I open up a particular Excel file a particular
wav/midi/mp3 music file will automatically start playing? If so, how do I
do it?

Thanks - Steve B.




  #3   Report Post  
Earl Kiosterud
 
Posts: n/a
Default

Bob,

Playsound won't play mp3 or mid files. All you'll hear is that "donk"
(which is ding.wav).
--
Earl Kiosterud
mvpearl omitthisword at verizon period net
-------------------------------------------

"Bob Phillips" wrote in message
...
Steve,

Put this code in a normal code module

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


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


and then in ThisWorkbook add this code



Private Sub Workbook_Open()

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

HTH

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


"SteBar" wrote in message
...
Is it possible that when I open up a particular Excel file a particular
wav/midi/mp3 music file will automatically start playing? If so, how do
I
do it?

Thanks - Steve B.






  #4   Report Post  
Bob Phillips
 
Posts: n/a
Default

Hi Earl,

Yes this only does WAV. You need separate code for MP3 and MIDI., and you
halved to stream it through the appropriate device AFAIK, so it is not
appropriate for this sort of use.

--

HTH

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


"Earl Kiosterud" wrote in message
...
Bob,

Playsound won't play mp3 or mid files. All you'll hear is that "donk"
(which is ding.wav).
--
Earl Kiosterud
mvpearl omitthisword at verizon period net
-------------------------------------------

"Bob Phillips" wrote in message
...
Steve,

Put this code in a normal code module

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


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


and then in ThisWorkbook add this code



Private Sub Workbook_Open()

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

Sub
--

HTH

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


"SteBar" wrote in message
...
Is it possible that when I open up a particular Excel file a particular
wav/midi/mp3 music file will automatically start playing? If so, how

do
I
do it?

Thanks - Steve B.








  #5   Report Post  
Dave Peterson
 
Posts: n/a
Default

So maybe you could use the windows default application that's associated with
that file extension:

Option Explicit
Private Sub Workbook_Open()
Shell "Start ""C:\My Documents\My Music\my song.mp3"""
End Sub

This starts it, but does give a warning message:
Option Explicit
Private Sub Workbook_Open()
ActiveWorkbook.FollowHyperlink "C:\My Documents\My Music\my song.mp3"
End Sub





Earl Kiosterud wrote:

Bob,

Playsound won't play mp3 or mid files. All you'll hear is that "donk"
(which is ding.wav).
--
Earl Kiosterud
mvpearl omitthisword at verizon period net
-------------------------------------------

"Bob Phillips" wrote in message
...
Steve,

Put this code in a normal code module

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


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


and then in ThisWorkbook add this code



Private Sub Workbook_Open()

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

HTH

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


"SteBar" wrote in message
...
Is it possible that when I open up a particular Excel file a particular
wav/midi/mp3 music file will automatically start playing? If so, how do
I
do it?

Thanks - Steve B.





--

Dave Peterson
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
Excel 2003 FAILS, but Excel 2000 SUCCEEDS ??? Richard Excel Discussion (Misc queries) 2 May 13th 23 11:46 AM
Read Text File into Excel Using VBA Willie T Excel Discussion (Misc queries) 13 January 8th 05 12:37 AM
Excel 2000 file when opened in Excel 2003 generates errors? Doug Excel Discussion (Misc queries) 13 December 25th 04 10:20 PM
double click a xls file and start Excel but without the file Danyi, Attila Excel Discussion (Misc queries) 2 December 22nd 04 02:19 PM
Saving a Excel 97 file into Excel 2003 file Wil Excel Discussion (Misc queries) 1 December 13th 04 11:51 PM


All times are GMT +1. The time now is 01:42 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"