0

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
robots.txt
  • 96
  • 2
  • 10
  • 36
  • 1
    Everything looks ok to me. You may see some entries missing becuase you are using `Debug` which prints to Immediate Window and the window has a limit to the text it can display. Try writing it to an excel sheet and then check if you are still missing data? – Siddharth Rout Mar 12 '19 at 10:45
  • Yes, I got everything when i wrote them to an excel sheet. I was not aware of this invaluable information `immediate window has a limit to the text it can display` @Siddharth Rout. Thanks a trillion. – robots.txt Mar 12 '19 at 11:06
  • Yes it has a limit of (if I am not wrong) 199 lines... – Siddharth Rout Mar 12 '19 at 11:10
  • Also, the watches/locals windows have a limited length for strings they will display. And some Excel-Functions are limited to 255 Characters, some more research can be found here: https://stackoverflow.com/questions/2516702/getting-around-the-max-string-size-in-a-vba-function – L8n Mar 12 '19 at 12:18

0 Answers0