View Single Post
 
Old 03-02-2020, 12:55 PM
pk_00 pk_00 is offline Windows 10 Office 2016
Novice
 
Join Date: Mar 2020
Posts: 1
pk_00 is on a distinguished road
Default ms word document text translation using vba code

I'm new to VBA and I want to translate word document text into another language (English to Telugu) I have hundreds of documents.
I want to automate this process using the macro.
This should work for one document later I can automate but as if know
I don't know how to translate one document and replace translated text, save and close.

Any help is appreciated
please see my code

Sub Translate_text()
Dim IE As Object 'for browser

ActiveDocument.Select 'select text from open document
Selection.Copy 'copy selected text
Set IE = CreateObject("InternetExplorer.Application") 'Create object for IE
With IE
.Visible = True
.Navigate "https://translate.google.com/#view=home&op=translate&sl=auto&tl=te" 'open the following Url
'--------------------------
Selection.Paste 'paste copied text in translator focused text area
'facing problem don't know the proper code
'Copy text from another text area
'don't know the code for it
'--------------------------
.Quit
End With
'-----------------------------

ActiveDocument.Replace 'replace in the active document
.Save
.Close
'-----------------------------
End Sub
Reply With Quote