Google Oversæt af Internet Explorer Automation Denne VBA makrokode oversætter tekst ved hjælp af Google Translate ved automatisering af Internet Explorer kontrolleres gennem Excel.
Forklaring Programmet automatisk skriver tekst fra Excel i Internet Explorer og bruger Google Translate service til at oversætte teksten i begær sprog. Det er muligt at oversætte fra og til mange forskellige sprog, bare ændre sprogkoden og programmet er sat op i overensstemmelse hermed. Hele VBA / Excel program kan hentes nederst på denne side, god fornøjelse!
Kode Public Sub Google_Translate ()
Dim Google_Translate_Internet_Explorer_Automation As Object 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
Kolonne = 0 While Range ("F9"). Offset (0, kolonne) .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, kolonne) .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"). Elementer (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, kolonne) .Value = tom Then
from_language_code = Range ("A10"). Offset (rad, 0) .Value Google_Translate_Internet_Explorer_Automation.document.forms ("text_form"). Elementer (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"). Elementer ("kilde") .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"). Indsende
While Google_Translate_Internet_Explorer_Automation.busy Call WaitSeconds (Wait_Between_Google_Translate_Cycles) Wend
DD2 = Google_Translate_Internet_Explorer_Automation.document.forms (1). elementer (4) .Value
While Google_Translate_Internet_Explorer_Automation.busy Call WaitSeconds (Wait_Between_Google_Translate_Cycles) Wend
Google_Translate_Variable1 = Erstat (DD2, Chr (13), "") Range ("F10"). Offset (rad, kolonne) .Value = Google_Translate_Variable1
End If
rad = rad + 1 Wend
Kolonne = Kolonne + 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 = Anden (Now()) + sek waitTime = TimeSerial (newHour, newMinute, newSecond) Application.Wait waitTime
End Sub
Download excel filen!Google_Translate_Internet_Explorer_Automation.xls |