ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Programming an unusual action (https://www.excelbanter.com/excel-programming/338157-programming-unusual-action.html)

Dave

Programming an unusual action
 
Is it possible to to create a macro that runs when you click on a worksheet
tab to open it, or to change the scripting to achieve that action?

Specifically, we would like to have a *.wav file play when a worksheet is
opened.

Thanks,
--
DAS

Bob Phillips[_6_]

Programming an unusual action
 
Here is an example

Option Explicit

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

Private Sub Worksheet_Activate()
sndPlaySound32 "c:\windows\media\ding.wav", 0
End Sub

'This is worksheet event code, which means that it needs to be
'placed in the appropriate worksheet code module, not a standard
'code module. To do this, right-click on the sheet tab, select
'the View Code option from the menu, and paste the code in.




--
HTH

Bob Phillips

"Dave" wrote in message
...
Is it possible to to create a macro that runs when you click on a

worksheet
tab to open it, or to change the scripting to achieve that action?

Specifically, we would like to have a *.wav file play when a worksheet is
opened.

Thanks,
--
DAS




Tom Ogilvy

Programming an unusual action
 
the workbook_Open event fires when a workbook is opened if the user does not
disable macros.

See Chip Pearson's page on events'
http://www.cpearson.com/excel/events.htm

for sounds:

http://support.microsoft.com/default...b;en-us;213777
XL2000: How to Play Sounds Using Visual Basic for Applications

http://support.microsoft.com/default...b;en-us;158140
XL: How to Play Sounds Using Visual Basic for Applications

http://support.microsoft.com/default...kb;en-us;86281
HOWTO: Play a Waveform (.WAV) Sound File in Visual Basic
[Contains the Constants for the Arguments]

http://support.microsoft.com/default...b;en-us;170730
WD: How to Play a .wav Sound File by Using a Macro

http://support.microsoft.com/default...b;en-us;211842
WD2000: How to Play a .wav Sound File Using a Macro

http://support.microsoft.com/default...b;en-us;193223
HOWTO: Use the MessageBeep API to Play System .WAV Files

--
Regards,
Tom Ogilvy


"Dave" wrote in message
...
Is it possible to to create a macro that runs when you click on a

worksheet
tab to open it, or to change the scripting to achieve that action?

Specifically, we would like to have a *.wav file play when a worksheet is
opened.

Thanks,
--
DAS




Dave

Programming an unusual action
 
Thanks a lot! -- Dave
--
DAS


"Bob Phillips" wrote:

Here is an example

Option Explicit

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

Private Sub Worksheet_Activate()
sndPlaySound32 "c:\windows\media\ding.wav", 0
End Sub

'This is worksheet event code, which means that it needs to be
'placed in the appropriate worksheet code module, not a standard
'code module. To do this, right-click on the sheet tab, select
'the View Code option from the menu, and paste the code in.




--
HTH

Bob Phillips

"Dave" wrote in message
...
Is it possible to to create a macro that runs when you click on a

worksheet
tab to open it, or to change the scripting to achieve that action?

Specifically, we would like to have a *.wav file play when a worksheet is
opened.

Thanks,
--
DAS





Dave

Programming an unusual action
 
Thank you very much!
--
DAS


"Tom Ogilvy" wrote:

the workbook_Open event fires when a workbook is opened if the user does not
disable macros.

See Chip Pearson's page on events'
http://www.cpearson.com/excel/events.htm

for sounds:

http://support.microsoft.com/default...b;en-us;213777
XL2000: How to Play Sounds Using Visual Basic for Applications

http://support.microsoft.com/default...b;en-us;158140
XL: How to Play Sounds Using Visual Basic for Applications

http://support.microsoft.com/default...kb;en-us;86281
HOWTO: Play a Waveform (.WAV) Sound File in Visual Basic
[Contains the Constants for the Arguments]

http://support.microsoft.com/default...b;en-us;170730
WD: How to Play a .wav Sound File by Using a Macro

http://support.microsoft.com/default...b;en-us;211842
WD2000: How to Play a .wav Sound File Using a Macro

http://support.microsoft.com/default...b;en-us;193223
HOWTO: Use the MessageBeep API to Play System .WAV Files

--
Regards,
Tom Ogilvy


"Dave" wrote in message
...
Is it possible to to create a macro that runs when you click on a

worksheet
tab to open it, or to change the scripting to achieve that action?

Specifically, we would like to have a *.wav file play when a worksheet is
opened.

Thanks,
--
DAS






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

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com