Я работаю над проектом для компании, в которой я работаю, и я новичок в VBA.Я пытаюсь зайти на сайт поставщика и перейти на страницу запроса цен.
Я могу войти, но после входа в систему я не могу заставить VBA щелкнуть гиперссылку, на которую я хочу, еслиЯ перешагиваю код, используя F8.Я пытался сделать паузу в определенных местах кода, но он все равно не работает.
Я разместил часть кода, которая вызывает проблемы.Любая помощь будет принята с благодарностью.
Sub getDurablePrices()
Dim IE As Object
Dim i As Long
Dim objElement As Object
Dim objCollection As Object
Set IE = CreateObject("InternetExplorer.Application")
IE.Navigate "http://duraweb.durableusa.com/Acct%20Mgmt/Login.aspx"
IE.Visible = True
Do While IE.Busy
'nothing
Loop
IE.document.All("htmUserName").Value = "******"
IE.document.All("htmPwd").Value = "******"
Set objCollection = IE.document.getElementsByTagName("input")
i = 0
While i < objCollection.Length
If objCollection(i).Type = "submit" Then
Set objElement = objCollection(i)
End If
i = i + 1
Wend
objElement.Click
'Code added as suggested.
Do While IE.Busy Or IE.readyState <> 4
DoEvents
Loop
Set AllHyperLinks = IE.document.getElementsByTagName("A")
For Each hyper_link In AllHyperLinks
If hyper_link.innerText = "Customer Price Inquiry" Then
hyper_link.Click
Exit For
End If
Next
End Sub
Вот HTML-код, который я пытаюсь нажать:
<a class="ctl00_ContentPlaceHolder1_MenuTree_0"
href="Customer/CustomerPriceInquiry.aspx"
id="ctl00_ContentPlaceHolder1_MenuTreet4">Customer Price Inquiry</a>