?
Solved

Need help with Outlook 2010 VB Script for Speaking Reminders

Posted on 2010-04-09
8
Medium Priority
?
671 Views
Last Modified: 2013-11-25
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
0
Comment
Question by:J-Antonio
  • 4
  • 4
8 Comments
 
LVL 59

Expert Comment

by:Chris Bottomley
ID: 30801704
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
 
LVL 1

Author Comment

by:J-Antonio
ID: 30839302
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
 
LVL 59

Expert Comment

by:Chris Bottomley
ID: 30845972
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 new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
LVL 1

Author Comment

by:J-Antonio
ID: 31139908
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
 
LVL 59

Expert Comment

by:Chris Bottomley
ID: 31162286
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
 
LVL 1

Author Comment

by:J-Antonio
ID: 31212881
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
 
LVL 59

Accepted Solution

by:
Chris Bottomley earned 2000 total points
ID: 31392671
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
 
LVL 1

Author Closing Comment

by:J-Antonio
ID: 31804651
Thanks for the try.  I appreciate that.  I guess it wasn't meant to be...  Take good care,  ~Antonio
0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

By default Outlook 2016 displays only one time zone in the Calendar. The following article explains how to display two time zones in one calendar view.
There can be many situations demanding the conversion of Outlook OST files to PST format and as such, there is no shortage of automated tools to perform this conversion. However, what makes Stellar OST to PST converter stand above the rest? Let us e…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
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 …
Suggested Courses

593 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