Error '70': Permission Denied

1

When I run the code below, the title error appears in the 'For Each' line. Is this a block from the site itself or does it have some error in the code?

Declara função Sleep
If VBA7 Then
    Public Declare PtrSafe Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As LongPtr) 'For 64 Bit Systems
Else
    Public Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long) 'For 32 Bit Systems
End If

Sub IPMO_semanal()

    Dim IE As Object
    Dim doc As MSHTML.HTMLDocument


    Set IE = CreateObject("InternetExplorer.Application")

    IE.navigate "http://ons.org.br/pt/paginas/conhecimento/acervo-digital/documentos-e-publicacoes?categoria=Relat%C3%B3rio+PMO"
    IE.Visible = True

Set el = IE.document.getElementsByTagName("table")

    Sleep 2000

    i = 1
    For Each link In el.getElementsByTagName("a")

    '      If EXTRAIRELEMENTO(link.href, 9, "/") = "InformePMO_MAR2018_RV4.pdf" Then
    '      If Mid(link.href, 105, 8) = "InformePMO" Then

           If link.href = "http://ons.org.br/_layouts/download.aspx?SourceUrl=http://ons.org.br/AcervoDigitalDocumentosEPublicacoes/InformePMO_MAR2018_RV4.pdf" Then
            i = i + 1

            link.Click
             Sleep 2000
            If i = 2 Then Exit For
        End If

    Next link


End Sub
    
asked by anonymous 29.03.2018 / 14:41

1 answer

1

Spun here, with a little detail:

The variable el is a collection of tables (even if it contains a single table), so it was necessary to change the For to reference the first element of el (ie el(0) ): p>

For Each link In el(0).getElementsByTagName("a")

In any case, you have not identified any instances of the link you specified.

    
24.04.2018 / 07:14