Solved

outlook 2010 repeating notifying sound

Posted on 2011-02-17
32
1,016 Views
Last Modified: 2012-05-11
How do I create a macro in Outlook 2010 that plays a repeating wav file when a mail message comes from a particular person.  I want a button to appear on the toolbar to stop the sound from repeating.  I aksed "Bluedevilfan" this for outlook 2003, but I've since "upgraded to windows 7 64 bit and outlook 2010 and things are much different (or at least they LOOK much different).
0
Comment
Question by:dfarr
  • 18
  • 14
32 Comments
 
LVL 76

Expert Comment

by:David Lee
ID: 34924811
Hi, dfarr.

Everything should work the same in Windows 7/Outlook 2010 except for the button.  Outlook 2010 does away with the toolbars in favor of the ribbon.  Unfortunately, adding things to the ribbon isn't as simple as it was to add things to toolbars.  The best solution is to add a button to the Qucik Access Toolbar, which is the toolbar that appears above the ribbon.  Here's a link to article that talks about the QAT.  You should be able to add a button that runs the macro that stops the sound.

http://www.addictivetips.com/windows-tips/office-2010-quick-access-toolbar/
0
 

Author Comment

by:dfarr
ID: 34937258
No good.  I get an error that says " compile error  the code in this project must be updated for 64 bit systems..."
0
 
LVL 76

Expert Comment

by:David Lee
ID: 34938480
Did you copy and paste the code in or did you just move the Outlook code file?
0
 

Author Comment

by:dfarr
ID: 34938501
copy/paste
0
 

Author Comment

by:dfarr
ID: 34938507
This is in Macro section:


 


Private Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA" _
(ByVal lpszSoundName As String, ByVal uFlags As Long) As Long
 
Const SND_ASYNC = &H1
Const SND_LOOP = &H8
Const SND_NODEFAULT = &H2
Const SND_SYNC = &H0
Const SND_NOSTOP = &H10
Const SND_MEMORY = &H4
 
Sub PlaySoundLoop(strCommand As String, strSound As String)
    Select Case LCase(strCommand)
        Case "start"
            sndPlaySound strSound, SND_LOOP + SND_ASYNC
        Case "stop"
            sndPlaySound vbNull, SND_ASYNC
    End Select
End Sub
 
'Duplicate this subroutine for each recipient you want to play a sound for.  Be sure to change the name.'
Sub PlayWarningA(Item As Outlook.MailItem)
    'Change the path and sound file name on the following line as desired'
    PlaySoundLoop "start", "C:\Windows\Media\Ding.wav"
End Sub
 
Sub PlayWarningB(Item As Outlook.MailItem)
    'Change the path and sound file name on the following line as desired'
    PlaySoundLoop "start", "C:\Windows\Media\SomeFile.wav"
End Sub
 
Sub StopWarning()
    PlaySoundLoop "stop"
End Sub


  nothing in "ThisOUTLOOKsession"
0
 
LVL 76

Expert Comment

by:David Lee
ID: 34938571
I just ran this very same code on my 64-bit Win7 system and it ran without a hitch.
0
 

Author Comment

by:dfarr
ID: 34938600
I have a button on the "toolbar"to stop the wav file from repeating, but cant see how to "edit" it.  Seems to me I recall having to edit the button in Outlook 2003.  Or is that automatically included as part of the "macro" in Visual basic?
0
 
LVL 76

Expert Comment

by:David Lee
ID: 34938616
No, the macro does not create the button.  The steps I'd given for adding a toolbar button won't work in Outlook 2010 because it doesn't use toolbars.  That's why I posted the link to creating a button on the QAT, which Outlook 2010 does have.  Have you gone through that and added a button?
0
 

Author Comment

by:dfarr
ID: 34938637
Yeah I meant QAT.  That;'s why I put Toolbar in Quotes.  I couldnt remember the name.  

Anyway, I am getting no sound I added it to Rules and have it "playing a script". but I get no sound at all
0
 

Author Comment

by:dfarr
ID: 34938652
the first two lines:

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


does this mean anything?

are in red
0
 
LVL 76

Expert Comment

by:David Lee
ID: 34938689
Yes.  Those lines are declaring an external function.  In this case it's the function that plays the sound.  If it's in red that means Outlook has a problem with those lines.  There are any number of possible reasons.  A non-printing character on the line, no space between the double-quote and the underscore character on the first line, the lines don't appear at the top of the module or are in a class module or ThisOutlookSession.
0
 

Author Comment

by:dfarr
ID: 34938702
So I should delete those lines???
0
 
LVL 76

Expert Comment

by:David Lee
ID: 34938720
They have to be there.  If that function isn't declared then the code can't call it.  If it can't call it, then it can't play a sound.  

What you need to do is try and figure out what's wrong with the line and fix it.  An alternative is to delete the lines and type them in manually.  You can also try deleting the underscore on the first line and pulling the contents of line 2 up to line 1.  Like this

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

Author Comment

by:dfarr
ID: 34938731
I did a cut/paste of the code you sent me and then deleted the old line.  But the line still appears in red.
0
 
LVL 76

Expert Comment

by:David Lee
ID: 34938760
Can you take and post a screenshot of the VB editor screen in Outlook showing the code?
0
 

Author Comment

by:dfarr
ID: 34938915
I can do a cut/paste:  I went back to the old computer I know this worked on and did a cut/paste into a word document and then transported that to the new computer and cut/pasted from word to Visual basic; but The first 2 lines are still showing up in red.  I have No idea of why its not working...

Private Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA" _
(ByVal lpszSoundName As String, ByVal uFlags As Long) As Long
 
Const SND_ASYNC = &H1
Const SND_LOOP = &H8
Const SND_NODEFAULT = &H2
Const SND_SYNC = &H0
Const SND_NOSTOP = &H10
Const SND_MEMORY = &H4
 
Sub PlaySoundLoop(strCommand As String, strSound As String)
    Select Case LCase(strCommand)
        Case "start"
            sndPlaySound strSound, SND_LOOP + SND_ASYNC
        Case "stop"
            sndPlaySound vbNull, SND_ASYNC
    End Select
End Sub
 
'Duplicate this subroutine for each recipient you want to play a sound for.  Be sure to change the name.'
Sub PlayWarningA(Item As Outlook.MailItem)
    'Change the path and sound file name on the following line as desired'
    PlaySoundLoop "start", "C:\INSTALLED SOFTWARE\Program Files (x86)\Nero\Nero 9\Nero Burning ROM\DingDong.wav"
End Sub
 
Sub PlayWarningmomdad(Item As Outlook.MailItem)
    'Change the path and sound file name on the following line as desired'
    PlaySoundLoop "start", "C:\answering machine messages\mail21.wav"
End Sub
 
 
Sub PlayWarningMike(Item As Outlook.MailItem)
    'Change the path and sound file name on the following line as desired'
    PlaySoundLoop "start", "C:\windows\media\mail78a.wav"
End Sub
 
Sub PlayWarningleslie(Item As Outlook.MailItem)
    'Change the path and sound file name on the following line as desired'
    PlaySoundLoop "start", "C:\windows\media\mail10c.wav"
End Sub
Sub StopWarning()


0
Control application downtime with dependency maps

Visualize the interdependencies between application components better with Applications Manager's automated application discovery and dependency mapping feature. Resolve performance issues faster by quickly isolating problematic components.

 
LVL 76

Expert Comment

by:David Lee
ID: 34938935
Try cutting and pasting to Notepad instead of Word.  Word is probably adding something that's causing the problem.
0
 
LVL 76

Expert Comment

by:David Lee
ID: 34938939
Also, what module is the code in?
0
 

Author Comment

by:dfarr
ID: 34938955
the code is in "this outlook session, same as on the other omputer.
0
 

Author Comment

by:dfarr
ID: 34939154
As you suggested, I tried copying/pasting using Notepad instead of Word.....no difference
0
 

Author Comment

by:dfarr
ID: 34939256
when I try to run the macro I keep getting an error message that says "Compile error:  The code in this project must be updated for use on 64 bit systems. Please review and update Declare statements and then mark them with the PtrSafe attribute."   I have no idea what that means; hopefully you do.
0
 

Author Comment

by:dfarr
ID: 34939305
Okay, heres what I've done.  After a bit of snooping on the web I added the phrase "PtrSafe" between the "Declare" and "function" in the script.  Immediately it turned from red to black.  I dont know what that means, but 1 problem solved....
0
 

Author Comment

by:dfarr
ID: 34939335
Okay, now I've got it doing the repeating wav file thing, now if you can tell me how to stop it via a button on the QAT. I think we'll be done.....
0
 
LVL 76

Expert Comment

by:David Lee
ID: 34939967
I've no idea what PtrSafe is.  I've never encountered that error.  As I mentioned, I copied the code and pasted it into my 64-bit Win7 system and it worked straight away.

Add a button the QAT that runs a macro.  It needs to run the macro named StopWarning.
0
 

Author Comment

by:dfarr
ID: 34941429
There is a button there.  its called project1StopWarning
0
 
LVL 76

Expert Comment

by:David Lee
ID: 34943468
Are you saying that when you click it the sound does not stop?
0
 

Author Comment

by:dfarr
ID: 34959114
For some strange reason, I had a button in there before.  And when I clicked on it nothing happened.  After I got the macro to MAKE the sound start working, then I added another button (with a different name) and IT appears to be working.  I've no idea of the "Whys" but it all seems to be working, now.  Thanks a lot ... again.  perhaps one of us should suggest this add-on to Microsoft for their next version??????  Maybe we could get some $$$ for the suggestion????
0
 
LVL 76

Expert Comment

by:David Lee
ID: 34972255
I'm not sure that many people would want a repeating sound.  I've never seen an add-in that implements that, so I'm guessing no one has asked before.  Still, I'll keep it in mind and perhaps mention it to the folks at Microsoft.
0
 

Author Comment

by:dfarr
ID: 34978186
I know they have it so that you hear 1 sound, but if you're not within hearing range of the computer at the time...that's pointless.....It'd sort of be like if you get a telephone call, but the phone only rings once.....
0
 
LVL 76

Expert Comment

by:David Lee
ID: 34985198
Well, sort of.  If the phone worked the same way as this, then on a missed call the phone would continue ringing even after the caller gave up and hung up.  
0
 

Author Comment

by:dfarr
ID: 34991000
True, true.....oh well.  Thanks for the help.  
0
 
LVL 76

Accepted Solution

by:
David Lee earned 500 total points
ID: 34991412
You're welcome.
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

This process describes the steps required to Import and Export data from and to .pst files using Exchange 2010. We can use these steps to export data from a user to a .pst file, import data back to the same or a different user, or even import data t…
Following basic email etiquette rules will help you write a professional email and achieve a good, lasting impression with your contacts.
This Experts Exchange video Micro Tutorial shows how to tell Microsoft Office that a word is NOT spelled correctly. Microsoft Office has a built-in, main dictionary that is shared by Office apps, including Excel, Outlook, PowerPoint, and Word. When …
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now