Buenas gente de Necesitomas! Gente que quiere y va a crecer.
Busco solucionar el problema que al ejecutar una macro da error 91 en tiempo de ejecucion.
Estaba viendo el video https://youtu.be/txctDNUOxIc donde te enseñan a extraer texto de pagina web y en la descripcion dejan el archivo excel del tutorial el cual es https://drive.google.com/file/d/1Jxu-nt3HbazrDwhriFYOP-kIEcJwvqk4/view.
El problemame surgió es que a los 2,42 min del video ejecutan una macro que se ejecuta perfectamente, y yo, que tengo el mismo archivo (supuestamente) cuando ejecuto la macro me sale un cartel diciendo "Se ha producido un error 91 en tiempo de ejecucion: variable de objeto o bloque With no establecido".
La macro que me produce (y las otras tambien) el error 91 es:
Sub ie_getElementById()
[a19] = ie.document.getElementById("pt-anontalk").innerText
End Sub
Quiero solucionar el problema pero no sé nada de programacíon.
Les agradezco si me dicen como es que tengo que editar el codigo.
En archivo de excel que se maneja en el video todas las macros son:
Dim ie As Object
Sub cciexploc()
Set ie = CreateObject("INTERNETEXPLORER.APPLICATION")
ie.NAVIGATE "https://es.wikipedia.org/wiki/Anexo:Pa%C3%ADses_de_Am%C3%A9rica_por_supe..."
ie.Visible = True
End Sub
Sub ie_getElementById()
[a19] = ie.document.getElementById("pt-anontalk").innerText
End Sub
Sub ie_getElementsByTagName()
[a20] = ie.document.getElementsByTagName("li")(2).innerText
End Sub
Sub ie_getElementsByClassName()
Debug.Print ie.document.getElementsByClassName("firstHeading")(0).innerText
End Sub
Sub ie_id_tag()
Debug.Print ie.document.getElementById("mw-content-text").getElementsByTagName("tr")(4).innerText
End Sub
Sub etiqueta_td_tr()
Debug.Print ie.document.getElementById("mw-content-text").getElementsByTagName("tr")(2).getElementsByTagName("td")(2).innerText
End Sub
Sub contar_tr()
Debug.Print ie.document.getElementById("mw-content-text").getElementsByTagName("tr").Length
End Sub
Sub contar_td()
Debug.Print ie.document.getElementById("mw-content-text").getElementsByTagName("td").Length
End Sub
Sub contar_tdtr()
Debug.Print ie.document.getElementById("mw-content-text").getElementsByTagName("tr")(1).getElementsByTagName("td").Length
End Sub
Sub etiqueta_td_for()
For i = 0 To 3
Debug.Print ie.document.getElementById("mw-content-text").getElementsByTagName("tr")(i).innerText
Next
End Sub
Sub ie_td_tr_for()
For i = 0 To 3
For j = 0 To 3
Set Cells(i + 1, j + 1) = ie.document.getElementById("mw-content-text").getElementsByTagName("tr")(i).getElementsByTagName("td")(j).innerText
Next
Next
End Sub
Sub todo()
Set ie1 = CreateObject("INTERNETEXPLORER.APPLICATION")
ie1.Visible = True
ie1.NAVIGATE "https://es.wikipedia.org/wiki/Anexo:Pa%C3%ADses_de_Am%C3%A9rica_por_supe..."
While ie1.ReadyState <> 4
DoEvents
Wend
[a26] = ie1.document.getElementById("pt-anontalk").innerText
ie1.Quit
End Sub