LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 536
Default Assign a sound to a variable

This is a shortened list of sounds in column R, sheet 1. And is the list for a data validation drop down in H1.

C:\Windows\Media\ir_end.wav
C:\Windows\Media\ringout.wav
C:\Windows\Media\Speech Misrecognition.wav

This is in Module 1:

Option Explicit

Private Declare Function sndPlaySound Lib "winmm.dll" _
Alias "sndPlaySoundA" (ByVal lpszSoundName As String, _
ByVal uFlags As Long) As Long

Const SND_SYNC = &H0
Const SND_ASYNC = &H1
Const SND_LOOP = &H8
Const SND_PURGE = &H40

Public Sub SoundPlayAsyncOnce(Sound As String)
'SND_SYNC to play assynchron
sndPlaySound Sound, SND_ASYNC
End Sub


This is in sheet1 vb editor:

Option Explicit

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

Sub TingleTunes()

'Dim iSnd As string
'Set iSnd = Range("H1").Value
'SoundPlayAsyncOnce iSnd.Value
'SoundPlayAsyncOnce iSnd.Value

SoundPlayAsyncOnce ActiveCell.Value
End Sub

As is, it works fine to select a sound in R column and run Sub TingleTunes().

The commented out code lines is my attempt to select a sound from the drop down and run TingleTunes to play the selected sound.

I get object required error.

Thanks.
Howard
 
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
Assign Sub Name to a Variable Alan Excel Programming 3 October 10th 06 04:20 PM
Assign value to a variable name Gnarlodious Excel Discussion (Misc queries) 2 August 20th 06 07:10 AM
Assign my own sound from a list to a command button emil Excel Programming 1 June 30th 06 02:16 AM
Assign value to variable rroach Excel Discussion (Misc queries) 1 July 13th 05 05:24 AM
assign variable Tim Excel Programming 10 October 1st 04 07:33 PM


All times are GMT +1. The time now is 02:54 PM.

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"