Moderatori: Anthony47, Flash30005
Sub GoogTrans2()
Dim IE As Object, Trans As String, snarT As String
Dim I As Long, LastA As Long, checkBack As Boolean
Dim Coll1 As Object, cTrad As String, getOut As Boolean
'
'Se Inglese ->Italiano:
Trans = "?sl=en&tl=it" '<<< SL=Inglese&TL=Italiano
snarT = "?sl=it&tl=en" '<<< SL=Italiano&TL=Inglese
checkBack = True '<<< Esegue traduzione al contrario? True /False
'
Set IE = CreateObject("InternetExplorer.Application")
IE.Visible = True
IE.navigate "https://translate.google.it/" & Trans & "&op=translate"
AppActivate Application.Caption
DoEvents
MsgBox ("Accettare le condizioni Google prima di chiudere il Messaggio")
LastA = Cells(Rows.Count, 1).End(xlUp).Row
For j = 1 To 2
IE.Visible = True
If j = 1 Then
operat = Trans & "&text="
Else
operat = snarT & "&text="
End If
For I = 2 To LastA
If Cells(I, j) <> "" Then
With IE
.navigate "https://translate.google.it/" & operat & Cells(I, j).Value & "&op=translate"
Application.Wait (Now + TimeValue("0:00:01"))
Do While .busY: DoEvents: Loop 'Attesa not busy
Do While .readyState <> 4: DoEvents: Loop 'Attesa documento
myWait (1)
Set Coll1 = IE.document.getElementsByClassName("J0lOec")
cTrad = ""
For k = 1 To 10
myWait (1)
If cTrad = IE.document.getElementsByClassName("J0lOec")(0).getElementsByTagName("span")(2).innertext Then
If getOut = True Then Exit For
getOut = True
Else
getOut = False
cTrad = IE.document.getElementsByClassName("J0lOec")(0).getElementsByTagName("span")(2).innertext
End If
Next k
Debug.Print cTrad
cTrad = ""
Set Coll1 = IE.document.getElementsByClassName("J0lOec")(0).getElementsByTagName("span")
For k = 0 To Coll1.Length - 1
If Left(Coll1(k).getAttribute("jsaction"), 6) = "click:" Then
Debug.Print k, Coll1(k).getAttribute("jsaction")
Debug.Print Coll1(k).innertext & vbCrLf
cTrad = cTrad & Coll1(k).innertext & vbCrLf
End If
Next k
Cells(I, 1 + j).Value = Replace(cTrad, "Ripristina originale", "", , , vbTextCompare)
End With
End If
Next I
If checkBack = False Then Exit For
Next j
' Stop 'solo uso debug, poi rimuovere
IE.Quit
Set IE = Nothing
MsgBox ("Comppletato...")
End Sub
Sub myWait(myStab As Single)
Dim myStTiM As Single
'
myStTiM = Timer
Do 'wait myStab
DoEvents
If Timer > myStTiM + myStab Or Timer < myStTiM Then Exit Do
Loop
End Sub
IE.Visible = True
Anthony ha scritto:All'inizio la macro si ferma con un message box probabilmente poco visibile che invita ad accettare i termini di utilizzo di Google propedeutici all'accesso al servizio; fatta questa accettazione devi attivare la finestra di Excel e chiudere il messagebox per continuare la macro.
Maury ha scritto:Quando poi si apre il Brouser Della Pagina Traslator di Google
La pagina Risulta Vuota ; Come se stesse aspettando un dato qualsiasi da tradurre
Torna a Applicazioni Office Windows
Inserire add.in nella barra di avvio veloce in excel 2003 Autore: Ricky0185 |
Forum: Applicazioni Office Windows Risposte: 4 |
Aggiornare cella con somma quando aggiungo nuova colonna Autore: marcopont |
Forum: Applicazioni Office Windows Risposte: 1 |
Excel: problema con date se devo unirle a testi Autore: valle1975 |
Forum: Applicazioni Office Windows Risposte: 4 |
confrontare e evidenziare 2 fogli excel Autore: niccia |
Forum: Applicazioni Office Windows Risposte: 7 |
Visitano il forum: Nessuno e 63 ospiti