Excel VBA-页面加载时单击Web元素?

时间:2019-03-08 18:42:06

标签: excel vba internet-explorer automation

我想知道页面加载时是否可以单击Web元素,这是我的代码,但是它不起作用:

Sub Link()

       Dim IE                  As InternetExplorer
       Dim lMaterial           As String
       Dim lObra               As String
       Dim Shell As Object
       'Dim IE As Object


       'ABRE O IE EXPANDIDO
       Set IE = CreateObject("InternetExplorer.Application")
       IE.Visible = 1
       IE.Toolbar = 0
       IE.MenuBar = 0

       'ABRE O SIENGE
       IE.Navigate "https://curyempreendimentos.sienge.com.br/sienge/MED/listLiberacoesMedicoes.do"
       'IDENTIFICA SE O SIENGE FOI TOTALMENTE CARREGADO
       Do While IE.Busy = True
           DoEvents
       Loop
       'IDENTIFICA SE O SIENGE FOI TOTALMENTE CARREGADO
       While IE.READYSTATE <> READYSTATE_COMPLETE
       Wend
       sng = timer
           Do While sng + 1 > timer
           Loop

       'INFORMA O Nº DO CONTRATO
       IE.Document.all("labelContrato").Value = ActiveCell
       Call IE.Document.parentWindow.execScript("javascript: CT_BLR(this);onChangeContrato(false)", "JavaScript")

       'CONSULTA MEDIÇÕES À SEREM LIBERADAS

       Do While IE.Busy = True

       Set elems = IE.Document.getElementsByTagName("input")
           For Each e In elems
               If (e.getAttribute("Value") = "Consultar") Then
                   e.Click
               Exit For
           End If
       Next e

       Loop

End Sub

0 个答案:

没有答案