Moderatori: Anthony47, Flash30005
Sub Call1()
Sheets("Foglio1").Select '<<< Il foglio su cui si fara' l'importazione
Range("A:X").ClearContents 'NB: Il fofglio SARA' AZZERATO senza preavviso
Range("A:X").NumberFormat = "@" 'Colonne in formato Testo
Call GetTabbbSub(Range("Y1").Value) ' "Chiama" la GetTabbbSub
Range("A:X").WrapText = False
End Sub
Sub GetTabbbSub(ByVal myURL As String)
'Va Chiamata passandogli l'URL da leggere
Dim IE As Object
'
Set IE = CreateObject("InternetExplorer.Application")
'
With IE
.navigate myURL
.Visible = True
'Stop 'Vedi TESTO
Do While .Busy: DoEvents: Loop 'Attesa not busy
Do While .readyState <> 4: DoEvents: Loop 'Attesa documento
End With
'
myStart = Timer 'attesa addizionale
Do
DoEvents
If Timer > myStart + 1 Or Timer < myStart Then Exit Do
Loop
'Scrive le tabelle SUL FOGLIO ATTIVO
Set myColl = IE.document.getElementsByTagName("TABLE")
For Each myItm In myColl
Cells(I + 1, 1) = "Table# " & ti + 1
ti = ti + 1: I = I + 1
For Each trtr In myItm.Rows
For Each tDtD In trtr.Cells
Cells(I + 1, j + 1) = tDtD.innerText
Cells(I + 1, j + 1).HorizontalAlignment = xlLeft
'Legge hyperlink:
If InStr(1, tDtD.innerHTML, "href", vbTextCompare) > 0 Then
DoEvents: DoEvents
On Error Resume Next
ActiveSheet.Hyperlinks.Add anchor:=Cells(I + 1, j + 1), _
Address:=tDtD.getElementsByTagName("a")(0).href
On Error GoTo 0
End If
If j > 0 And Len(Cells(I + 1, j + 1)) > 2 Then cz = 1
j = j + 1
Next tDtD
'Allinea al centro se e' una Intestazione:
If trtr.className = "js-tournament" Then
Cells(I + 1, 1).HorizontalAlignment = xlCenter
End If
I = I + 1: j = 0
DoEvents
Next trtr
I = I + 1
Next myItm
'
'Chiusura IE
IE.Quit
Set IE = Nothing
End Sub
Sub Call1()
'' Sheets("Foglio1").Select '<<< Il foglio su cui si fara' l'importazione
Range("A:X").ClearContents 'NB: Il fofglio SARA' AZZERATO senza preavviso
Range("A:X").NumberFormat = "@" 'Colonne in formato Testo
Call GetTabbbSub(Range("Y1").Value) ' "Chiama" la GetTabbbSub
Range("A:X").WrapText = False
End Sub
Sub GetTabbbSub(ByVal myURL As String)
'Va Chiamata passandogli l'URL da leggere
Dim IE As Object, PH2 As Boolean
Set IE = CreateObject("InternetExplorer.Application")
'
With IE
.navigate myURL
.Visible = True
'Stop 'Vedi TESTO
End With
Fase2:
With IE
Do While .Busy: DoEvents: Loop 'Attesa not busy
Do While .readyState <> 4: DoEvents: Loop 'Attesa documento
End With
'
myStart = Timer 'attesa addizionale
Do
DoEvents
If Timer > myStart + 1 Or Timer < myStart Then Exit Do
Loop
If PH2 = False Then
IE.document.getElementById("mutual_div").getElementsByTagName("a")(0).Click
' IE.document.getElementById("mutual_div").getElementsByTagName("a")(0).FireEvent "onclick"
PH2 = True
GoTo Fase2
End If
'Scrive le tabelle SUL FOGLIO ATTIVO
Set myColl = IE.document.getElementsByTagName("TABLE")
For Each myItm In myColl
Cells(I + 1, 1) = "Table# " & ti + 1
ti = ti + 1: I = I + 1
For Each trtr In myItm.Rows
For Each tDtD In trtr.Cells
Cells(I + 1, j + 1) = tDtD.innerText
Cells(I + 1, j + 1).HorizontalAlignment = xlLeft
'Legge hyperlink:
If InStr(1, tDtD.innerHTML, "href", vbTextCompare) > 0 Then
DoEvents: DoEvents
On Error Resume Next
ActiveSheet.Hyperlinks.Add anchor:=Cells(I + 1, j + 1), _
Address:=tDtD.getElementsByTagName("a")(0).href
On Error GoTo 0
End If
If j > 0 And Len(Cells(I + 1, j + 1)) > 2 Then cz = 1
j = j + 1
Next tDtD
'Allinea al centro se e' una Intestazione:
If trtr.className = "js-tournament" Then
Cells(I + 1, 1).HorizontalAlignment = xlCenter
End If
I = I + 1: j = 0
DoEvents
Next trtr
I = I + 1
Next myItm
'
'Chiusura IE
IE.Quit
Set IE = Nothing
End Sub
Torna a Applicazioni Office Windows
Importare immagini a seconda del testo in una cella Autore: Paolo67met |
Forum: Applicazioni Office Windows Risposte: 4 |
Importare anche gli url con selenium Autore: aggittoriu |
Forum: Applicazioni Office Windows Risposte: 3 |
Sempre su Autohotkey...importare dati e copiarli in file.txt Autore: Paolo67met |
Forum: Programmazione Risposte: 27 |
Importare più file di testo contemporaneamente Autore: Paolo67 |
Forum: Applicazioni Office Windows Risposte: 2 |
Macro per importare dati dalla Lottomatica. Autore: nelson1331 |
Forum: Applicazioni Office Windows Risposte: 32 |
Visitano il forum: Marius44 e 38 ospiti