#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default sound

I am trying to click on a cell and have it play a wav file.... I have that
part working fine ( I belive )

But when I close excel after playing 1 or more wavs if always ask me if I
want to save changes
and I get the popup after only playing a file...no other changes.
Is there a way around this.... thanks



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


Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As
Boolean)

Dim WFile As String

WFile = ActiveCell.Value + ".wav"
WFile = ThisWorkbook.Path & "\" & WFile
PlayWavFile (WFile)
End Sub


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default sound

You may want to try an undo

from
PlayWavFile (WFile)
to
PlayWavFile (WFile)
application.Undo

"dougw" wrote:

I am trying to click on a cell and have it play a wav file.... I have that
part working fine ( I belive )

But when I close excel after playing 1 or more wavs if always ask me if I
want to save changes
and I get the popup after only playing a file...no other changes.
Is there a way around this.... thanks



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


Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As
Boolean)

Dim WFile As String

WFile = ActiveCell.Value + ".wav"
WFile = ThisWorkbook.Path & "\" & WFile
PlayWavFile (WFile)
End Sub



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default sound

The double click event places the selected cell in edit mode. Exiting edit
mode will change the Saved property of the file you are in to false thus
requiring a save. If you add Cancel = True to your existing code you will not
end up in edit mode and that should keep you from needing a save...

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As
Boolean)

Dim WFile As String

Cancel = True
WFile = ActiveCell.Value + ".wav"
WFile = ThisWorkbook.Path & "\" & WFile
PlayWavFile (WFile)
End Sub

--
HTH...

Jim Thomlinson


"dougw" wrote:

I am trying to click on a cell and have it play a wav file.... I have that
part working fine ( I belive )

But when I close excel after playing 1 or more wavs if always ask me if I
want to save changes
and I get the popup after only playing a file...no other changes.
Is there a way around this.... thanks



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


Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As
Boolean)

Dim WFile As String

WFile = ActiveCell.Value + ".wav"
WFile = ThisWorkbook.Path & "\" & WFile
PlayWavFile (WFile)
End Sub



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default sound

Thanks Joel and Jim for your replies...

Jim, I tried the Cancel = True, yes it does cancel the edit mode but still
prompts for a save.

Joel, when I added the Application.Undo, the first time I run it I get error
1004 which is an
application-defined or object-defined error.its a catch-all error. So I
trapped the error and
that works... But if I add or change anything somewhere else in the sheet...
than click on
a cell to play the file... it does an undo and removes the last data
inputed.

OK ,will have to dig a little deeper into some programming books see if I
can find something else..

Thanks again to both of you for your replies




"Jim Thomlinson" wrote in message
...
The double click event places the selected cell in edit mode. Exiting edit
mode will change the Saved property of the file you are in to false thus
requiring a save. If you add Cancel = True to your existing code you will
not
end up in edit mode and that should keep you from needing a save...

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As
Boolean)

Dim WFile As String

Cancel = True
WFile = ActiveCell.Value + ".wav"
WFile = ThisWorkbook.Path & "\" & WFile
PlayWavFile (WFile)
End Sub

--
HTH...

Jim Thomlinson


"dougw" wrote:

I am trying to click on a cell and have it play a wav file.... I have
that
part working fine ( I belive )

But when I close excel after playing 1 or more wavs if always ask me if I
want to save changes
and I get the popup after only playing a file...no other changes.
Is there a way around this.... thanks



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


Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As
Boolean)

Dim WFile As String

WFile = ActiveCell.Value + ".wav"
WFile = ThisWorkbook.Path & "\" & WFile
PlayWavFile (WFile)
End Sub





  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default sound

hmmmmmmmm, Well I am in no way an expert with excel or VBA programming.
This is an update for something I found out on the superinformation highway
( hope that does not date me ... lol )... seems that adding this line stops
it from
asking for the save. ActiveCell.Offset(0, 0).Select. So I added it the end
of my sub:

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As
Boolean)

Dim WFile As String

WFile = ActiveCell.Value + ".wav"
WFile = ThisWorkbook.Path & "\" & WFile
PlayWavFile (WFile)
ActiveCell.Offset(0, 0).Select
End Sub


works like a charm.... thanks again

========================================
"dougw" wrote in message
news:WrW_j.298528$pM4.11715@pd7urf1no...
I am trying to click on a cell and have it play a wav file.... I have that
part working fine ( I belive )

But when I close excel after playing 1 or more wavs if always ask me if I
want to save changes
and I get the popup after only playing a file...no other changes.
Is there a way around this.... thanks



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


Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As
Boolean)

Dim WFile As String

WFile = ActiveCell.Value + ".wav"
WFile = ThisWorkbook.Path & "\" & WFile
PlayWavFile (WFile)
End Sub



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
Sound when a value is entered. Loren Excel Discussion (Misc queries) 2 April 9th 09 11:33 PM
Sound alert Antonio Excel Discussion (Misc queries) 3 May 30th 06 07:09 PM
can I add sound to a spreadsheet? add sound to spreadsheet Excel Discussion (Misc queries) 4 February 20th 06 11:08 PM
playing sound??? tess457[_6_] Excel Programming 2 October 20th 04 11:50 AM
This may sound stupid..... anthonyenglish Excel Programming 3 October 14th 04 07:05 PM


All times are GMT +1. The time now is 03:14 AM.

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"