Display disrupted by program not responding event when using .SPEAK for longer text

  • Purpose
    [1] Audio Excel training document for SPANISH.
    [2] Macro SPEAKS cell text by row and column in either ENGLISH or SPANISH
    [3] User follows the text with the speaker.


    Issue
    [1] Short text (7-8 words) is spoken without an issue.
    [2] The display is interrupted by a "SentenceStructure - Saved" Not Responding for longer text (GT 8-9 words)
    [3] The display is restored upon completion of the long text


    Problem
    Prevent the screen display from being interrupted by the Not Responding event


    CODE
    Option Base 1


    Sub Run_Affirmative() [INDENT]srcsht = "Affirmative"[/INDENT]
    [INDENT]Dim spnstring As String
    colArray1 = Array("E", "F", "G", "H", "I", "J", "K", "L")[/INDENT]
    [INDENT]limcol1 = UBound(colArray1)
    colArray2 = Array("M", "N", "O", "P", "Q", "R", "S", "T")
    limcol2 = UBound(colArray2)


    For r = 2 To 126[/INDENT]
    [INDENT=2]voyce = Sheets(srcsht).Range("D" & r).Value
    If voyce = 0 Or voyce = 5 Then
    DoEvents
    For c = 1 To limcol1[/INDENT]
    [INDENT=3]DoEvents
    If Sheets(srcsht).Range(colArray1(c) & r).Value gt 0 Then[/INDENT]
    [INDENT=4]DoEvents
    psetym = Mid(100 + (Sheets(srcsht).Range(colArray1(c) & r).Value \ 3), 2, 2)
    spnstring = Sheets(srcsht).Range(colArray2(c) & r).Text
    If Mid(spnstring, 1, 1) = "-" Then voyce = 0
    Sheets(srcsht).Range("M" & r).Select
    psetym = "0:00:" & psetym
    Application.ScreenUpdating = False
    DoEvents
    TalkInLanguage spnstring, voyce, psetym
    Application.ScreenUpdating = True
    DoEvents[/INDENT]
    [INDENT=3]End If[/INDENT]
    [INDENT=2]Next c
    End If[/INDENT]
    [INDENT]Next r[/INDENT]
    End Sub


    Sub TalkInLanguage(Words As String, voyce, psetym)
    Dim Voc As SpeechLib.SpVoice
    Set Voc = New SpVoice
    DoEvents


    With Voc [INDENT]Set .Voice = .GetVoices.Item(voyce)
    .Rate = -1
    .Volume = 100
    .Speak Words, False[/INDENT]
    End With


    Application.Wait (Now + TimeValue(psetym))
    End Sub


    SAMPLE EXCEL SHEET: Columns A thru T
    [TABLE="border: 0, cellpadding: 0, cellspacing: 0, width: 1133"]

    [tr]


    [TD="width: 12"] [/TD]
    [TD="width: 64"] [/TD]
    [TD="width: 64"] [/TD]
    [TD="class: xl66, width: 26"] [/TD]
    [TD="class: xl68, width: 26"] [/TD]
    [TD="class: xl68, width: 26"] [/TD]
    [TD="class: xl68, width: 26"] [/TD]
    [TD="class: xl68, width: 26"] [/TD]
    [TD="class: xl68, width: 26"] [/TD]
    [TD="class: xl68, width: 26"] [/TD]
    [TD="class: xl68, width: 26"] [/TD]
    [TD="class: xl68, width: 26"] [/TD]
    [TD="class: xl65, width: 141"] [/TD]
    [TD="width: 141"] [/TD]
    [TD="width: 141, align: left"] [TABLE="cellpadding: 0, cellspacing: 0"]

    [tr]


    [TD="width: 141"] [/TD]

    [/tr]


    [/TABLE]
    [/TD]
    [TD="width: 141"] [/TD]
    [TD="width: 141"] [/TD]
    [TD="width: 141"] [/TD]
    [TD="width: 141"] [/TD]
    [TD="width: 141"] [/TD]

    [/tr]


    [tr]


    [td][/td]


    [TD="align: right"]1[/TD]
    [TD="align: right"]14[/TD]
    [TD="class: xl66, align: right"]0[/TD]
    [TD="align: right"]2[/TD]
    [TD="align: right"]0[/TD]
    [TD="align: right"]0[/TD]
    [TD="align: right"]0[/TD]
    [TD="align: right"]0[/TD]
    [TD="align: right"]0[/TD]
    [TD="align: right"]0[/TD]
    [TD="align: right"]0[/TD]
    [TD="class: xl71, width: 282, colspan: 2"]AFFIRMATIVE SENTENCES[/TD]

    [td][/td]


    [td][/td]


    [td][/td]


    [td][/td]


    [td][/td]


    [td][/td]


    [/tr]


    [tr]


    [td][/td]


    [TD="align: right"]1[/TD]
    [TD="align: right"]14[/TD]
    [TD="class: xl66, align: right"]5[/TD]
    [TD="align: right"]3[/TD]
    [TD="align: right"]0[/TD]
    [TD="align: right"]0[/TD]
    [TD="align: right"]0[/TD]
    [TD="align: right"]0[/TD]
    [TD="align: right"]0[/TD]
    [TD="align: right"]0[/TD]
    [TD="align: right"]0[/TD]
    [TD="class: xl70, width: 282, colspan: 2"]Las oraciones afirmativas[/TD]

    [td][/td]


    [td][/td]


    [td][/td]


    [td][/td]


    [td][/td]


    [td][/td]


    [/tr]


    [tr]


    [td][/td]


    [TD="align: right"]1[/TD]
    [TD="align: right"]14[/TD]
    [TD="class: xl66, align: right"]9[/TD]
    [TD="align: right"]0[/TD]
    [TD="align: right"]0[/TD]
    [TD="align: right"]0[/TD]
    [TD="align: right"]0[/TD]
    [TD="align: right"]0[/TD]
    [TD="align: right"]0[/TD]
    [TD="align: right"]0[/TD]
    [TD="align: right"]0[/TD]
    [TD="class: xl65, width: 141"] [/TD]

    [td][/td]


    [td][/td]


    [td][/td]


    [td][/td]


    [td][/td]


    [td][/td]


    [td][/td]


    [/tr]


    [tr]


    [TD="class: xl67"] [/TD]
    [TD="align: right"]1[/TD]
    [TD="align: right"]14[/TD]
    [TD="class: xl66, align: right"]0[/TD]
    [TD="align: right"]37[/TD]
    [TD="align: right"]0[/TD]
    [TD="align: right"]0[/TD]
    [TD="align: right"]0[/TD]
    [TD="align: right"]0[/TD]
    [TD="align: right"]0[/TD]
    [TD="align: right"]0[/TD]
    [TD="align: right"]0[/TD]
    [TD="class: xl69, width: 1128, colspan: 8"]Affirmative sentences declare an action or fact. They usually consist of at least a subject and a verb. In Spanish grammar, the subject generally comes at the beginning of the sentence, however, this order can be changed.[/TD]

    [/tr]


    [tr]


    [td][/td]


    [TD="align: right"]1[/TD]
    [TD="align: right"]14[/TD]
    [TD="class: xl66, align: right"]9[/TD]
    [TD="align: right"]0[/TD]
    [TD="align: right"]0[/TD]
    [TD="align: right"]0[/TD]
    [TD="align: right"]0[/TD]
    [TD="align: right"]0[/TD]
    [TD="align: right"]0[/TD]
    [TD="align: right"]0[/TD]
    [TD="align: right"]0[/TD]
    [TD="class: xl65, width: 141"] [/TD]

    [td][/td]


    [td][/td]


    [td][/td]


    [td][/td]


    [td][/td]


    [td][/td]


    [td][/td]


    [/tr]


    [/TABLE]

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!