my vba codes are in french, how can i quickly convert them to english

Brass Contributor

I am trying to convert my vba codes from french to english; there are 11 sheets and each has at least one code. I've just been slowly translating the codes with ChatGPT and Google Translate, but both of those have a limit to how much they can translate at a time.


Is there a quicker way for me to translate the codes?


Screenshot 2023-03-09 134611.png

4 Replies


Attached is a link and VBA Code with a solution approach


With Google translator service.

The idea of using this automatically with VB/VBA.

Requirements are: Connection to the web and Internet Explorer/Edge.

Here is the procedure:





Public Function TranslateByGoogle(OrigineText As String, _
   LangCodeFrom As String, _
   LangCodeTo As String, _
   TranslateText As String, _
   Optional UniCodeID As Long, _
   Optional TimeOutSeconds As Integer = 3, _
   Optional ErrSilent As Boolean = False) As Boolean
'Copyright by Jean Pierre Allain

   Dim ieOBJ As Object, WaitTime As Date
   ' Google website
   Const WebSite As String = ""
   ' error handling
   OnError GoTo ErrHandler
   If Len(OrigineText) > 0 And Not LangCodeFrom = LangCodeTo Then
     ' Create IE object (instance).
     Set ieOBJ = CreateObject("InternetExplorer.Application")
     'Call up website with parameters
     ieOBJ.Navigate WebSite & "/?sl=" & LangCodeFrom & _
       "&tl=" & LangCodeTo & "#" & LangCodeTo & "|" & _
       LangCodeFrom & "|" & OrigineText
     ' Set TimeOut
     WaitTime = Now + TimeValue("00:00:" & TimeOutSeconds)
     On Error Resume Next
       ' Read Google result
       TranslateText = ieOBJ.Document.getElementById("result_box").innerText
       If Now() >= WaitTime Then Exit Do
     Loop While TranslateText = ""
     OnError GoTo ErrHandler
     ' Read result (translation)
     If Len(TranslateText) > 0 And Not TranslateText = OrigineText Then
       ' If necessary, convert the translation into the specified national language
       If UniCodeID <> 0 Then
         TranslateText = StrConv(TranslateText, vbUnicode, UniCodeID)
       End If
       TranslateByGoogle = True
     End If
   End If
   On Error Resume Next
   ' Destroy objects
   Set ieOBJ = Nothing
   Exit function
   If Not ErrSilent Then
     MsgBox Err.Description, vbCritical, Err.Number
   End If
   Resume ExitProc
End function







Dim Result As String
' Language codes must be passed as ISO country codes
' Example: German = DE
' English = EN
' French = FR
' Polish = PL
' etc.
If TranslateByGoogle("That was easy!", "DE", "EN", Result) Then
End If




Maybe it will help you :)

I'm having trouble figuring out how to run this code; how do I use it?



I am using also this code from J.Pierre Allain to translate text via VBA and it does not work for me , too.

The result Translate_Text stays to be "", no matter how many seconds I spend (e.g. 12).

Any ideas where or why it fails ?

Alternatives known ? 


The Translate feature is currently available for Word, Excel, OneNote, Outlook, and PowerPoint.

Translate text into a different language


In addition, a file for your own translator to install yourself, I have it from the Internet.

Find creator and page in the file. Maybe it will help you.

At the same time I found the site of the creator of the first code.

Here the link: Use Google Translate with VB and Internet Explorer


Hope it helps!