- Codice: Seleziona tutto
Sub IMPORTADATI()
myURL = "https://www.cftc.gov/dea/futures/financial_lf.htm"
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
Sheets("IMPORTADATI").Activate
Sheets("IMPORTADATI").Select
Cells.Clear
Set mycoll = IE.document.getElementsByTagName("pre")
mySplit = Split(mycoll(0).innertext, Chr(10), , vbBinaryCompare)
Range("A1").Resize(UBound(mySplit) + 1, 1).Value = Application.WorksheetFunction.Transpose(mySplit)
'Debug.Print objIE.document.getElementsByTagName("p")(4).textContent
IE.Quit
Set IE = Nothing
End Sub
La macro funziona e importa i dati, il problema è di come vengono importati, tutti nella colonna A e questo rende molto difficile poi recuperarli (essendo anche stringhe molto lunghe) in quanto salta la normale impaginazione della tabella.
Qualche consiglio di come dovrei fare?