Google Translate av Internet Explorer Automation Detta VBA makrokod översätter text med hjälp av Google Översätt genom automatisering av Internet Explorer kontrolleras genom Excel.
Förklaring Programmet skriver automatiskt text från Excel i Internet Explorer och använder Google Translate tjänsten att översätta texten till önskningar språk. Det är möjligt att översätta till och från många olika språk, bara ändra språket koden och programmet är inställd detta. Hela VBA / Excel-programmet finns att ladda ner längst ner på denna sida, njut!
Kod Public Sub Google_Translate ()
Dim Google_Translate_Internet_Explorer_Automation As Objekt Set Google_Translate_Internet_Explorer_Automation = CreateObject ("InternetExplorer.Application") Google_Translate_Internet_Explorer_Automation.Navigate "http://translate.google.com/translate_t #" Google_Translate_Internet_Explorer_Automation.Visible = True Wait_Between_Google_Translate_Cycles = Range ("G1") .Value
Kolumn = 0 While Range (F9). Offset (0, kolumn) .Value <> tom
Do While Google_Translate_Internet_Explorer_Automation.busy Call WaitSeconds (Wait_Between_Google_Translate_Cycles) Loop
to_language_code = Range (F9). Offset (0, kolumn) .Value
Do While Google_Translate_Internet_Explorer_Automation.busy Call WaitSeconds (Wait_Between_Google_Translate_Cycles) Loop
Google_Translate_Internet_Explorer_Automation.document.forms ("text_form"). Element (5) .Value = to_language_code
Do While Google_Translate_Internet_Explorer_Automation.busy Call WaitSeconds (Wait_Between_Google_Translate_Cycles) Loop
rad = 0 While Range ("C10"). Offset (rad, 0) .Value <> tom
If Range ("F10"). Offset rad (kolumn) .Value = tom Then
from_language_code = Range ("A10"). Offset (rad, 0) .Value Google_Translate_Internet_Explorer_Automation.document.forms ("text_form"). Element (4) .Value = from_language_code
Do While Google_Translate_Internet_Explorer_Automation.busy Call WaitSeconds (Wait_Between_Google_Translate_Cycles) Loop
Google_Translate_Text = Range ("C10"). Offset (rad, 0) .Value
While Google_Translate_Internet_Explorer_Automation.busy Call WaitSeconds (Wait_Between_Google_Translate_Cycles) Wend
Google_Translate_Internet_Explorer_Automation.document.forms ("text_form"). Element ("källa") .Value = Google_Translate_Text
While Google_Translate_Internet_Explorer_Automation.busy Call WaitSeconds (Wait_Between_Google_Translate_Cycles) Wend
Google_Translate_Internet_Explorer_Automation.document.getElementById ("text_form"). Förelägga
While Google_Translate_Internet_Explorer_Automation.busy Call WaitSeconds (Wait_Between_Google_Translate_Cycles) Wend
DD2 = Google_Translate_Internet_Explorer_Automation.document.forms (1). element (4) .Value
While Google_Translate_Internet_Explorer_Automation.busy Call WaitSeconds (Wait_Between_Google_Translate_Cycles) Wend
Google_Translate_Variable1 = Ersätt DD2 (, Chr (13), "") Range ("F10"). Offset (rad, kolumn) .Value = Google_Translate_Variable1
End If
rad = rad + 1 Wend
Kolumn = Kolumn + 1 Wend
Google_Translate_Internet_Explorer_Automation.Quit Set Google_Translate_Internet_Explorer_Automation = Nothing
End Sub
Public Sub WaitSeconds (SEK)
newHour = Hour (Now()) newMinute = Minute (Now()) newSecond = Andra (Now()) + kr waitTime = TimeSerial (newHour, newMinute, newSecond) Application.Wait waitTime
End Sub
Ladda ner Excel-fil!Google_Translate_Internet_Explorer_Automation.xls |