I've created a macro to parse some links and their concerning texts from a webpage. When I print the result in within fetchData()
, I get them all. But, when I print the result in printResult()
, I get very few of them.
How can I print all the result in another sub, as in printResult()
?
Sub fetchData()
Const baseUrl = "https://www.psacard.com"
Const link = "https://www.psacard.com/psasetregistry/baseball/company-sets/16"
Dim Http As New XMLHTTP60, Html As New HTMLDocument
Dim post As Object, nUrl$, sName$
With Http
.Open "GET", link, False
.send
Html.body.innerHTML = .responseText
End With
For Each posts In Html.getElementsByTagName("td")
If posts.getElementsByTagName("a").Length Then
nUrl = baseUrl & Split(posts.getElementsByTagName("a")(0).getAttribute("href"), "about:")(1)
sName = posts.getElementsByTagName("a")(0).innerText
printResult nUrl, sName
End If
Next posts
End Sub
Sub printResult(ByVal nUrl As String, ByVal sName As String)
Debug.Print nUrl, sName
End Sub