Html 我正在尝试将超链接打印到excel工作表的“类”下;搜索结果";。VBA元素中需要更改哪些内容?

Html 我正在尝试将超链接打印到excel工作表的“类”下;搜索结果";。VBA元素中需要更改哪些内容?,html,excel,vba,internet-explorer,hyperlink,Html,Excel,Vba,Internet Explorer,Hyperlink,编辑:感谢您亲爱的朋友提供的解决方案 'GRV website copy and collect hyperlink Sub Get_HyperLink1() Dim ie As InternetExplorer Application.ScreenUpdating = False Set ie = New InternetExplorer ie.Visible = True Set ws = ThisWorkbook.Worksheets("Sheet1") Dim h

编辑:感谢您亲爱的朋友提供的解决方案

'GRV website copy and collect hyperlink
Sub Get_HyperLink1()

Dim ie As InternetExplorer
Application.ScreenUpdating = False
Set ie = New InternetExplorer
ie.Visible = True

Set ws = ThisWorkbook.Worksheets("Sheet1")
Dim http As New XMLHTTP60, html As New HTMLDocument
Dim nodeRaceResultsTable As HTMLHtmlElement
Dim nodeTr As HTMLHtmlElement
Dim nodeDiv As HTMLHtmlElement
Dim Element1 As HTMLHtmlElement
Dim node1 As HTMLHtmlElement
Dim currentUrl As String

With ie
    ie.Visible = True
下面的网站是我希望VBA导航的地方

ie.Navigate "https://fasttrack.grv.org.au/Meeting/Search?MeetingDateFrom=22%2F04%2F2020&MeetingDateTo=22%2F04%2F2020&Status=&TimeSlot=&DayOfWeek=&DisplayAdvertisedEvents=false&AllTracks=True&SelectedTracks=AllTracks&searchbutton=Search"
    Do Until .readyState = 4: DoEvents: Loop
End With
我正在尝试使用下面的VBA元素获取超链接

For Each nodeRaceResultsTable In html.getElementsByClassName("search-results")
For Each nodeTr In nodeRaceResultsTable.getElementsByTagName("tr")
    With nodeTr.getElementsByTagName("td")
下面的部分是我希望这个VBA抓取超链接并将其打印在excel工作表上的地方

    ws.Cells(5, 5) = .Item(1).getElementsByTagName("a")(0).href
    End With
Next
Next

    ie.Quit
    Set ie = Nothing
    Application.StatusBar = ""
    Application.ScreenUpdating = True

End Sub

试着这样做:

'GRV website copy and collect hyperlink
Sub Get_HyperLink1()

    Dim IE As New InternetExplorer
    With IE
        .Visible = True
        .navigate "https://fasttrack.grv.org.au/Meeting/Search?MeetingDateFrom=22%2F04%2F2020&MeetingDateTo=22%2F04%2F2020&Status=&TimeSlot=&DayOfWeek=&DisplayAdvertisedEvents=false&AllTracks=True&SelectedTracks=AllTracks&searchbutton=Search"

        While .Busy Or .readyState < 4: DoEvents: Wend
        Dim aTag As Object, i As Long
        Set aTag = IE.document.querySelectorAll(".search-results [href]")
        
        For i = 0 To aTag.Length - 1
            ActiveSheet.Cells(i + 1, 1) = aTag.Item(i)
        Next i
        
        IE.Quit
    End With

End Sub
'GRV网站复制和收集超链接
Sub Get_HyperLink1()
Dim IE成为新的InternetExplorer
与IE
.Visible=True
.导航“https://fasttrack.grv.org.au/Meeting/Search?MeetingDateFrom=22%2F04%2F2020&MeetingDateTo=22%2F04%2F2020&Status=&TimeSlot=&DayOfWeek=&DisplayAdvertisedEvents=false&AllTracks=True&SelectedTracks=AllTracks&searchbutton=Search"
当.Busy或.readyState<4:DoEvents:Wend时
Dim aTag作为对象,我作为
设置aTag=IE.document.querySelectorAll(“.search results[href]”)
对于i=0到总长度-1
活动表单元格(i+1,1)=表项(i)
接下来我
即退出
以
端接头

尝试以下方法:

'GRV website copy and collect hyperlink
Sub Get_HyperLink1()

    Dim IE As New InternetExplorer
    With IE
        .Visible = True
        .navigate "https://fasttrack.grv.org.au/Meeting/Search?MeetingDateFrom=22%2F04%2F2020&MeetingDateTo=22%2F04%2F2020&Status=&TimeSlot=&DayOfWeek=&DisplayAdvertisedEvents=false&AllTracks=True&SelectedTracks=AllTracks&searchbutton=Search"

        While .Busy Or .readyState < 4: DoEvents: Wend
        Dim aTag As Object, i As Long
        Set aTag = IE.document.querySelectorAll(".search-results [href]")
        
        For i = 0 To aTag.Length - 1
            ActiveSheet.Cells(i + 1, 1) = aTag.Item(i)
        Next i
        
        IE.Quit
    End With

End Sub
'GRV网站复制和收集超链接
Sub Get_HyperLink1()
Dim IE成为新的InternetExplorer
与IE
.Visible=True
.导航“https://fasttrack.grv.org.au/Meeting/Search?MeetingDateFrom=22%2F04%2F2020&MeetingDateTo=22%2F04%2F2020&Status=&TimeSlot=&DayOfWeek=&DisplayAdvertisedEvents=false&AllTracks=True&SelectedTracks=AllTracks&searchbutton=Search"
当.Busy或.readyState<4:DoEvents:Wend时
Dim aTag作为对象,我作为
设置aTag=IE.document.querySelectorAll(“.search results[href]”)
对于i=0到总长度-1
活动表单元格(i+1,1)=表项(i)
接下来我
即退出
以
端接头

我假设您的代码可以工作,但是否将链接作为纯文本输入?如果是这样,您可以使用
=HYPERLINK()
公式。它可以抓取超链接并将它们粘贴到工作表中。我建议你把答案标为接受。它可以在将来帮助其他社区成员解决类似的问题。谢谢你的理解。我假设你的代码可以工作,但是把链接放在纯文本中?如果是这样,您可以使用
=HYPERLINK()
公式。它可以抓取超链接并将它们粘贴到工作表中。我建议你把答案标为接受。它可以在将来帮助其他社区成员解决类似的问题。感谢您的理解。
aTag.Item(i).href
aTag.Item(i).href