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