Ciao ragazzi,
ho un problema con una sub che sto facendo.
Praticamente il codice che mi accingo a postare apre una serie di indirizzi del tipo:
http://maps.google.com/maps?saddr=-3...3.1139,151.514
da un foglio di excel.
Quando la pagina si apre mostra tra le varie cose la distanza tra due coordinate.
La mia sub prende la pagina web ed estrae il contenuto dei tag di tipo SPAN mettendoli in una object collection.
Ora non ci crederete ma dopo avere fatto tutto sto sbattimento non riesco ad estrarre nulla dall'oggetto "objCollection".
Sto usando Target = objCollection(i).Value per estrarre la stringa che mi interessa ma ricevo il seguente errore:
Run-time error '438':
Object doesn.t support this property or method
In pratica la domanda e': "ma come cavolo si estrae una stringa dalla collection che ho fatto?"
allego qui sotto il codice:
codice:Sub Test() Dim lngLastRow As Long Dim lngLoopCtr As Long Dim ie As Object Dim location As String Dim i As Integer Dim sFileName As String Dim iFileNum As Integer Dim sBuf As String Dim Fields As String Dim Target As String Dim objCollection As Object Dim objElement As Object Set ie = CreateObject("INTERNETEXPLORER.APPLICATION") lngLastRow = Range("G" & Rows.Count).End(xlUp).Row Set ie = CreateObject("INTERNETEXPLORER.APPLICATION") For lngLoopCtr = 2 To lngLastRow Step 1 If Cells(lngLoopCtr, "G") = "" Then Cells(lngLoopCtr, "G").Select Exit For End If Cells(lngLoopCtr, "G").Select location = Cells(ActiveCell.Row, "G") ie.navigate location ie.Visible = True While ie.Busy Application.Wait DateAdd("s", 1, Now) DoEvents Wend Set objCollection = ie.document.getElementsByTagName("SPAN") i = 0 While i < objCollection.Length ' Set text for search 'Target = objCollection(i).Value i = i + 1 Wend Application.Wait Now + TimeValue("00:00:04") Next lngLoopCtr End Sub
Grazie a Presto.

Rispondi quotando