New Member
Mar 21, 2014

I am new in this forum, but have monitored long time and have become a big fans of it.
This forum had helped me a lot in vba excel problems.
However this time I couldn't find any answer for my new issue to use
I have function which work perfectly with google translate using msxml2.xmlhttp and tried to modify it using the same method but I have lost because don't understand how to compose the url.

Here's the code I used for a long time using google translate and worked charmly (I got this from this marvelous forum as well ;) ):

Function getGoogleTranslation(strSource As String, strSourceLang As String, strDestLang As String) As String
Dim strURL As String, x As String

strURL = "" & _
Replace(strSource, " ", "%20") & _
"&hl=en&sl=" & strSourceLang & _
"&tl=" & strDestLang & "&multires=1&pc=0&rom=1&sc=1"

With CreateObject("msxml2.xmlhttp")
.Open "get", strURL, False
x = .responseText
End With
getGoogleTranslation = x
End Function

To use this function I used below codes extracting the results returned by analyzing any word functions available.
This below codes is not relevant though to my question (just need to describe what it does entirely).

Sub Translate

'Translated Words will be divided as each word functions
WordFunction = Split("conjunction,preposition,verb,noun,particle,adjective,prefix,interjection,suffix,complement", ",")

With ActiveSheet
SourceLang = "" 'Auto Detect so I leave it blank.
TargetLang = GetLang(.Range("B1")) 'GetLang is another function to convert eg: english > en, french > fr, etc...

'Get the total rows of data source
lRow = .Range("A" & .Rows.Count).End(xlUp).Row

'Run a cycle through each rows
For r = 2 To lRow

If Not IsEmpty(str) Then

translateResults = getGoogleTranslation(str, SourceLang, TargetLang)

'Main Translated words
.Range("B" & r) = Replace(Replace(Split(translateResults, Chr(34) & "," & Chr(34))(0), "[", ""), """", "")

'Other words
col = 0
For Each c In WordFunction
WFpos = InStr(1, translateResults, c)
If WFpos > 0 Then
intStart = InStr(WFpos, translateResults, ",[") + 3
intEnd = InStr(intStart, translateResults, "],")
otherWords = Split(Replace(Mid(translateResults, intStart, intEnd - intStart), Chr(34), ""), ",")
For Each w In otherWords
.Cells(r, 3 + col) = w
col = col + 1
Next w
End If
Next c

End If

Next r
End With

End Sub

It would be great if someone can give me a clue on how to compose the correct url to use the translation.babylon website like used in above function with google translate:

strURL = "" & _
Replace(strSource, " ", "%20") & _
"&hl=en&sl=" & strSourceLang & _
"&tl=" & strDestLang & "&multires=1&pc=0&rom=1&sc=1"

I hope I am not confusing you, excuse me for my english, I am from Indonesia.
Thank you all excel expert, really appreciate your time to read this :)

Best Wishes,
Daniel G. Pratidya

Forum statistics

Latest member

Some videos you may like

This Week's Hot Topics

  • populate from drop list with multiple tables
    Hi All, i have a drop list that displays data, what i want is when i select one of those from the list to populate text from different tables on...
  • Find list of words from sheet2 in sheet1 before a comma and extract text vba
    Hi Friends, Trying to find the solution on my task. But did not find suitable one to the need. Here is my query and sample file with details...
  • Dynamic Formula entry - VBA code sought
    Hello, really hope one of you experts can help with this - i've spent hours on this and getting no-where. .I have a set of data (more rows than...
  • Listbox Header
    Have a named range called "AccidentsHeader" Within my code I have: [CODE]Private Sub CommandButton1_Click() ListBox1.RowSource =...
  • Complex Heat Map using conditional formatting
    Good day excel world. I have a concern. Below link have a list of countries that carries each country unique data. [URL...
  • Conditional formatting
    Hi good morning, hope you can help me please, I have cells P4:P54 and if this cell is equal to 1 then i want row O to say "Fully Utilised" and to...