Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Sound files VBA programmed from Excel

I would like to play a singular music file from my 'I tune' collection when
a particular cell in my excel workbook turne from a"0" to a "1". Is there a
simple solution ??
--
bert
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 434
Default Sound files VBA programmed from Excel

hi, Hubert !

I would like to play a singular music file from my 'I tune' collection
when a particular cell in my excel workbook turne from a "0" to a "1".
Is there a simple solution ??


simple ?... i don't know how simple could you find the use of vba...
here is the basis: - http://www.cpearson.com/Excel/excelM.htm#PlayWAV

if any doubts (or further information)... would you please comment ?
hth,
hector.


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Sound files VBA programmed from Excel


--
bert


"Héctor Miguel" wrote:

hi, Hubert !

I would like to play a singular music file from my 'I tune' collection
when a particular cell in my excel workbook turne from a "0" to a "1".
Is there a simple solution ??


simple ?... i don't know how simple could you find the use of vba...
here is the basis: - http://www.cpearson.com/Excel/excelM.htm#PlayWAV

if any doubts (or further information)... would you please comment ?
hth,
hector.


does this only work on/with *.wav files??
Bert
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 284
Default Sound files VBA programmed from Excel

Bert,

What is the file type of the music file you want played? Would you
typically be able to play it with Windows Media Player?

Steve Yandl


"Hubert" wrote in message
...

--
bert


"Héctor Miguel" wrote:

hi, Hubert !

I would like to play a singular music file from my 'I tune' collection
when a particular cell in my excel workbook turne from a "0" to a "1".
Is there a simple solution ??


simple ?... i don't know how simple could you find the use of vba...
here is the basis: - http://www.cpearson.com/Excel/excelM.htm#PlayWAV

if any doubts (or further information)... would you please comment ?
hth,
hector.


does this only work on/with *.wav files??
Bert



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 434
Default Sound files VBA programmed from Excel

hi, Bert !

does this only work on/with *.wav files??


AFAIK for other comperssion formats (avi, mp3, ...) of sound files you can use the MCI functions
BTW, some this functions might require the path to the file in the (ancient) 8+3 filename format

this is an example of what how i use a UDF (called from my worksheets) like many others *IF* functions:

[A1] is the path to any folder containing the sound files
(i.e.) c:\documents and settings\<my profile\desktop\my music\

[A2] is the name of the file i want to be played if condition is met
(i.e.) led zeppelin - stairway to heaven.mp3

[A3] is the name of the file i want to be played if condition is NOT met
(i.e.) pink floyd - time.mp3

[A4] is a "flag" to play/stop the music (if its playing)
(i.e.) 0/1 or false/true

[A5] is the cell i want to be conditioned for play one of the files above
(i.e.) 20

the UDF is called (say in B5) using this sintax: - =Play_IF(a5,"=",26,a1&a2,a1&a3,a4)

in a standard code module, the required declarations, functions and procedures as follows...

if any doubt (or further information)... sould you please comment ?
regards,
hector.

' API functions entries '
Declare Function mciExecute Lib "winmm.dll" ( _
ByVal lpCommand As String) As Long
Declare Function GetShortPathName Lib "kernel32" _
Alias "GetShortPathNameA" ( _
ByVal LongPath As String, _
ByVal ShortPth As String, _
ByVal Buffer As Long) As Long

' UDF to obtain the ShortPath to the files '
Private Function StripName(ByVal LongName As String) As String
Dim Pos As Byte, ShortName As String
ShortName = Space(128)
Pos = GetShortPathName(LongName, ShortName, Len(ShortName))
StripName = LCase(Left(ShortName, Pos))
End Function

' this is the UDF called in worksheets cells ... '
' modify, adapt, ... as needed '
Function Play_IF(ByVal Compare As Variant, _
ByVal Operator As String, _
ByVal Condition As Variant, _
ByVal sndFileYes As String, _
Optional ByVal sndFileNo As String = "", _
Optional ByVal Action As Boolean = True) As String
Dim Command As String: Command = IIf(Action, "play ", "stop ")
If Evaluate("""" & Compare & """" & Operator & """" & Condition & """") Then
If Dir(sndFileNo) < "" Then mciExecute "stop " & StripName(sndFileYes)
If Dir(sndFileYes) < "" Then mciExecute Command & StripName(sndFileYes)
Play_IF = "Condition met !!!"
ElseIf Dir(sndFileNo) < "" Then
If Dir(sndFileYes) < "" Then mciExecute "stop " & StripName(sndFileYes)
mciExecute Command & StripName(sndFileNo)
Play_IF = "Condition failed !!!"
Else: Play_IF = "Condition failed !!!"
End If
End Function




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 Header formatting with a programmed field Bob Reynolds[_4_] Excel Programming 1 June 22nd 08 11:53 PM
Programmed pause Sam Excel Programming 2 April 8th 08 06:55 PM
sound files in excel? dkimball New Users to Excel 1 March 25th 05 12:06 AM
HOW TO PLAY SOUND.WAV FILES SIMULTANEOUSLY UNDER EXCEL Hotbird[_4_] Excel Programming 3 January 28th 05 03:16 PM
Excel menu programmed in .Net through PIA Avi Farah Excel Programming 0 November 10th 03 02:57 PM


All times are GMT +1. The time now is 12:04 AM.

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

About Us

"It's about Microsoft Excel"