宏未点击网站VBA代码中的“ href”链接

时间:2019-10-11 13:36:40

标签: html excel vba

我想从Excel中执行一个代码,该代码可以从网站打开发票搜索窗口。我得到了代码,但是宏没有单击“ href”,也没有给出任何错误。请您帮我解决问题。

Sub ExceltoHTML()    
Dim ie As New SHDocVw.InternetExplorer
Dim ies As New SHDocVw.InternetExplorer
Dim HTMLDOC As MSHTML.HTMLDocument
Dim HTMLINPUT As MSHTML.IHTMLElement
Dim HTMLAS As MSHTML.IHTMLElementCollection
Dim HTMLA As MSHTML.IHTMLElement
 ie.Visible = True
 ie.Navigate "https://travelex-prod.proactisp2p.com/ClassicP2P/Invoicing/Home.aspx"

Do While ie.ReadyState <> READYSTATE_COMPLETE

Loop

Set HTMLDOC = ie.Document
Set HTMLAS = HTMLDOC.getElementsByTagName("a")
For Each HTMLA In HTMLAS
'Debug.Print HTMLA.getAttribute("Classname"), HTMLA.getAttribute("href"), HTMLA.getAttribute("rel")

If HTMLA.getAttribute("href")="https://travelexprod.proactisp2p.com/ClassicP2P/Invoicing/Plus/ViewInvoiceSearch.aspx" Then
    HTMLA.Click
End If

0 个答案:

没有答案