Changing Text To Speech Language using VBA code RRS feed

  • Question

  • Hello all,

    I am trying to build a small application for my daughter to help her with her foreign language spelling revision (Spanish). 

    I have downloaded the language packs and installed the language object libraries in VBA.

    My question is, is it possible to change the language using say a VBA command so that it will speak Spanish  for some phrases and then back to English for the translation when say a button on a user form is pressed.

    Thank you very much in advance for any help you can provide

    Tuesday, November 21, 2017 10:28 AM

All replies

  • Hi gvpiper777, good father,

    Firstly, language pack is for display language in Excel. I'm afraid the language pack has nothing related with your needs.

    Secondly, I would like to confirm:
    (1) Do you intend to use Excel for your needs, instead of Word?
    (2) Which language is used in some phrases? Is it Spanish or English?
    (3) Do you intend to translate Spanish into English?  
    # I'm trying to make a sample (in Excel) for Speech and Translation.
       If I could understand your intention, I'll continue to work. 



    Wednesday, November 22, 2017 4:57 AM
  • Hello,

    You could use Speech.Speak Method (Excel)

    Sub Button1_Click()
    Application.Speech.Speak transalte_using_vba(ActiveCell.Value)
    Application.Speech.Speak ActiveCell.Value
    End Sub
    Function transalte_using_vba(str As String) As String
        Dim IE As Object, i As Long
        Dim result_data As String
        Set IE = CreateObject("InternetExplorer.application")
        IE.Visible = False
        IE.navigate "" & str
        Do Until IE.ReadyState = 4
        CLEAN_DATA = Split(Replace(IE.Document.getElementById("result_box").innerHTML, "</SPAN>", ""), "<")
        For j = LBound(CLEAN_DATA) To UBound(CLEAN_DATA)
            result_data = result_data & Right(CLEAN_DATA(j), Len(CLEAN_DATA(j)) - InStr(CLEAN_DATA(j), ">"))
        transalte_using_vba = result_data
    End Function




    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact

    Wednesday, November 22, 2017 6:49 AM