Change Translator to Bing Microsoft Translator

boboyj

New Member
Joined
May 31, 2014
Messages
6
I have been using Google Translate in my VBA code Function which is working perfectly fine for me. However, I have noticed that the translation they have for ARABIC is not as accurate as that with Bing Microsoft Translator which makes me decide to replace my current translator in the function with this. However, I am somehow unable to generate the same result using the link for Bing Microsoft Translator in the code itself.
Please can someone help me modify the code in the below function I am using.

Code:
Private Function Translate_using_vba(str As String) As String
' Tools Refrence Select Microsoft internet Control
    Dim IE As Object, i As Long, j As Long
    Dim inputstring As String, outputstring As String, text_to_convert As String, result_data As String, CLEAN_DATA
    Set IE = CreateObject("InternetExplorer.application")
    '   TO CHOOSE INPUT LANGUAGE
    inputstring = "ar"
    '   TO CHOOSE OUTPUT LANGUAGE
    outputstring = "en"
    text_to_convert = str
    
    'open website
    IE.Visible = False
   
 IE.Navigate "https://translate.google.com/?hl=en&tab=wT/#" & inputstring & "/" & outputstring & "/" & text_to_convert
   
   'I want to replace above line with the below but this doesn't work.
   'IE.Navigate "https://www.bing.com/translator/?ref=TThis&&text=&from=&to=en/#" & inputstring & "/" & outputstring & "/" & text_to_convert
 
   Do Until IE.ReadyState = 4
        DoEvents
    Loop
    Application.Wait (Now + TimeValue("0:00:5"))
    Do Until IE.ReadyState = 4
        DoEvents
    Loop
    CLEAN_DATA = Split(Application.WorksheetFunction.Substitute(IE.Document.getElementById("result_box").innerHTML, "", ""), "<")
    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), ">"))
    Next
    IE.Quit
    Translate_using_vba = result_data
End Function
Thank you so much for the assistance.
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.

Forum statistics

Threads
1,223,888
Messages
6,175,212
Members
452,618
Latest member
Tam84

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top