Moderatori: Anthony47, Flash30005
myURL = "http://www.statistichesulcalcio.com/mainstats/italia/Serie-A_71/anno_117.html "
Next trtr 'ESISTENTE
I = I + 2 'Modificata
Cells(I, "A").Value = "TABELLA_" & KK: KK = KK + 1 'AGGIUNTA
Next myItm 'ESISTENTE
Sub GetWebTab2()
Dim IE As Object, F As Long
Dim myRColl, myDColl, KK As Long, I As Long, J As Long, myColl, myR, myTD
'
myURL = "http://www.statistichesulcalcio.com/mainstats/italia/Serie-A_71/anno_117.html" '<<<<
Set IE = CreateObject("InternetExplorer.Application")
'
With IE
.navigate myURL
.Visible = True
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 + 2 Or Timer < myStart Then Exit Do
Loop
'Leggi le tabelle su foglio5 (su un nuovo foglio)
'Worksheets.Add '<<<<<1 -Nuovo foglio
Application.Goto (Sheets("Foglio2").Range("A1")) '<<<<<2 -Foglio esistente
Cells.Clear
Set myColl = IE.Document.getElementsbyTagName("TABLE")
For Each myItm In myColl
Cells(I + 1, "A").Value = "TABELLA_" & KK: KK = KK + 1: I = I + 1
For Each trtr In myItm.Rows
For Each tdtd In trtr.Cells
Cells(I + 1, J + 1) = tdtd.innertext
J = J + 1
Next tdtd
I = I + 1: J = 0
Next trtr
I = I + 2
Next myItm
'Legge le tabelle dentro gli iframe:
Set myColl = IE.Document.getElementsbyTagName("iframe")
For F = 0 To myColl.Length - 1
If Left(myColl(F).ID, 7) = "myframe" Then
Set my2coll = myColl(F).contentDocument.getElementsbyTagName("table")
For Each myItm In my2coll
Cells(I + 1, "A").Value = "TABELLA_" & KK: KK = KK + 1: I = I + 1
Set myRColl = myItm.getElementsbyTagName("tr")
For Each myR In myRColl
Set myDColl = myR.getElementsbyTagName("td")
For Each myTD In myDColl
Cells(I + 1, J + 1) = myTD.innertext
J = J + 1
Next myTD
I = I + 1: J = 0
Next myR
I = I + 2
Next myItm
End If
Next F
'
Cells.WrapText = False
Range("A1").Select
'
'Stop 'Vedi testo
'
'Chiusura IE
IE.Quit
Set IE = Nothing
End Sub
Ma la riga di codice evidenziata era la prima o la seconda riportata? Nel tuo file, un foglio che si chiama Foglio2 esiste? Quandi dici "ho eseguito istruzioni, fino a quando non mi dava l'errore" vuoi dire che non a ogni esecuzione di macro hai l' errore o che cosa?Grazie Anthony, ho eseguito istruzioni, fino a quando non mi dava l'errore, mi è comparso su questa riga
Application.Goto (Sheets("Foglio2").Range("A1")) '<<<<<2 -Foglio esistente
Cells.Clear
Torna a Applicazioni Office Windows
Inserire dati filtrati da 2 file ad un terzo file Autore: Ricky0185 |
Forum: Applicazioni Office Windows Risposte: 14 |
Perchè l'importazione dati con Selenium non fuziona? Autore: aggittoriu |
Forum: Applicazioni Office Windows Risposte: 7 |
copia di dati da un file chiuso e elaborazione Autore: luca62 |
Forum: Applicazioni Office Windows Risposte: 2 |
Visitano il forum: Nessuno e 11 ospiti