Need help with Outlook 2010 VB Script for Speaking Reminders

Hello Experts,

A very kind and knowledgeable Expert wrote a VBA Script for me which speaks the Reminders in Outlook 2010 (originally it was in 2007) when they pop up.  

It works great, except that I sometimes get an error when it first runs.  A copy of a screen capture of the error is attached to this message.

Also, for some reason, even though my name, Antonio, is before the script subroutine (I think), it speaks it at _every_ reminder, "Antonio do this", "Antonio remember that".  I would just like it to speak my name when the reminder window pops up, then announce/speak all of the Reminder Subjects.  

Furthermore, I understand from researching this that there are ways to alter the voice, and the speed of the speech.  If this is not too difficult, I would like to know how to do this as well.

Thank you for your kind consideration of my issue.  I am grateful for any input.  I am learning VBA, but it is slow going, and I want to learn to make this work as soon as I can.

A copy of the VB script is also attached, if I can figure out the correct way to do that _and_ attach the error image.  If not, I will post it in a reply to this post.

Best regards,

~Antonio
Private Sub Application_Reminder(ByVal Item As Object)
 
Dim synth As SpVoice ' Create the speech Object
Set synth = New SpVoice ' Set it to a new SP voice Class

synth.Speak "Antonio"

Select Case Item.Class
     Case olAppointment '26
        synth.Speak Item.Subject, SVSFlagsAsync + SVSFPurgeBeforeSpeak
      Case olMail '43
        synth.Speak Item.Subject, SVSFlagsAsync + SVSFPurgeBeforeSpeak
      Case olTask '48
        synth.Speak Item.Subject, SVSFlagsAsync + SVSFPurgeBeforeSpeak
End Select
Do
    DoEvents
Loop Until synth.WaitUntilDone(10)
 
Set synth = Nothing
 
End Sub

Open in new window

VB-Script-Error-Message-Capture.png
LVL 1
J-AntonioAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Chris BottomleySoftware Quality Lead EngineerCommented:
Application_Reminder is run once per reminder that is due hence it is called in it's entirity each time.  It will be difficult to change this and be seamless though in theory a task could be triggered for one minute hence that does the speech with the reminders updating a global string that is used by the timed task.

Chris
0
J-AntonioAuthor Commented:
Thanks Chris,
I kind of realized this just a day or so ago.  That, even if they are separate Reminder Subjects, each Reminder is treated as a different "event" by Outlook, so that means there is no real way for it to distinguish, unless, as you said, there was an update to the global string.  So, it runs the script on each reminder event.
I have also had the code re-written, as attached, so that there are no errors, and I have the speech slowed down to where I would like.  If I could only change the speaking voice...  Is there an easy way to do that with this script?
Take good care,
~Antonio

Private Sub Application_Reminder(ByVal Item As Object)

    On Error GoTo errHdr

    Dim synth As Object
    Set synth = CreateObject("SAPI.SpVoice")
    
    If synth Is Nothing Then
        MsgBox "[Error]=" & " can not create voice object ."
        GoTo exitHere
    End If

    synth.Rate = -1      'speak speed'
    synth.Volume = 100  'speak volume

    synth.Speak "Antonio"
    
    Select Case Item.Class
        Case 26, 43, 48
            synth.Speak Item.Subject, 3
    End Select

    Do
        DoEvents
    Loop Until synth.WaitUntilDone(10)
     
    Set synth = Nothing

If False Then
errHdr:
        MsgBox "[Error]=" & Err.Description, vbInformation + vbOKOnly
End If

exitHere:
End Sub

Open in new window

0
Chris BottomleySoftware Quality Lead EngineerCommented:
Assuming you have multiple voices then:

    synth .getvoices.item (0)

Will be the default and 1 ... number will be the additional voices.

Chris
0
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

J-AntonioAuthor Commented:
Hello Chris!
I tried adding that, using the number 2 instead of 1, and got the error message seen in the attached image.  
Is there any easy way to allow Outlook access to the speaking voices that are part of the Windows 7 OS?
I await your thoughtful reply.
Best regards,
~Antonio

Capture.PNG
0
Chris BottomleySoftware Quality Lead EngineerCommented:
The fact that 0 works and perhaps 1 implies that the mechanism is the same in win 7 but that the extra voices are not registered to sapi.  At this point I don't know but i'll try and look around to see if I can get any clues.

Chris
0
J-AntonioAuthor Commented:
That's alright, if it is not on the "tip of your tongue", don't worry about it.  I don't want you to spend your time on something so trivial...  I just thought it was easy.
Thanks, though!
~Antonio
0
Chris BottomleySoftware Quality Lead EngineerCommented:
I've had multiple tries, and cannot get the alternative voices to work ... they always come out as 'Anna' so i've given up, sorry

Chris
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
J-AntonioAuthor Commented:
Thanks for the try.  I appreciate that.  I guess it wasn't meant to be...  Take good care,  ~Antonio
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.