1
I have an Excel macro that connects to a local tool and extracts the information.
Basically I take a report according to the user. I have a column with users, however if the user does not present results in a day the tool triggers an alert and application to in the loop.
I’ve tried using IE.Sendkeys "{ENTER"} And error treats as on error GoTo and I got no result.
On Error Resume Next
Dim IE As Object
Plan1.Range("A5:L1000000").ClearContents
Set IE = CreateObject("InternetExplorer.Application")
IE.Visible = True
IE.Navigate "https://link portal"
    While IE.Busy Or IE.ReadyState <> 4
    Wend
IE.document.getElementById("txtUsuario").Value = "user"
IE.document.getElementById("txtSenha").Value = "pass"
IE.document.getElementById("btnLogar").Click
    While IE.Busy Or IE.ReadyState <> 4
    Wend
IE.Navigate "https://link para extrair relatorio"
While IE.Busy Or IE.ReadyState <> 4
    Wend
Dim i As Integer
aux = 2
Dim cont As Integer
cont = 5
While Plan2.Range("A" & aux).Value <> ""
    IE.document.getElementById("txtAgente").Value = Plan2.Range("A" & aux).Value
    IE.document.getElementById("calDataInicial_DateText").Value = Me.TextBox1.Text
    IE.document.getElementById("calDataFinal_DateText").Value = Me.TextBox1.Text
    IE.document.getElementById("imgPesquisar").Click
    While IE.Busy Or IE.ReadyState <> 4
        Wend 'a execução é interrompida aqui
   Set tabela = IE.document.all.tags("table")(7)
    For Each linha In tabela.all.tags("tr")
            Data = linha.all.tags("td")(0).innertext
            cpf = linha.all.tags("td")(1).innertext
            fila = linha.all.tags("td")(2).innertext
            operacao = linha.all.tags("td")(3).innertext
            contrato = linha.all.tags("td")(4).innertext
            agente = linha.all.tags("td")(5).innertext
            telefone = linha.all.tags("td")(6).innertext
            extensao = linha.all.tags("td")(7).innertext
            data_pagto = linha.all.tags("td")(8).innertext
            data_agen = linha.all.tags("td")(9).innertext
            motivo = linha.all.tags("td")(10).innertext
            obs = linha.all.tags("td")(11).innertext
            linha.MoveNext
            Plan1.Range("A" & cont) = Data
            Plan1.Range("B" & cont) = cpf
            Plan1.Range("C" & cont) = fila
            Plan1.Range("D" & cont) = operacao
            Plan1.Range("E" & cont) = contrato
            Plan1.Range("F" & cont) = agente
            Plan1.Range("G" & cont) = telefone
            Plan1.Range("H" & cont) = extensao
            Plan1.Range("I" & cont) = data_pagto
           ' Plan1.Range("J" & cont) = data_agen
            Plan1.Range("J" & cont) = motivo
            Plan1.Range("K" & cont) = obs
            cont = cont + 1
        Next
        aux = aux + 1
 Wend
 IE.Quit
 IE.nothing
						
