jeudi 19 septembre 2019

Clicking on a Link via Excel VBA - getElementsByTagName doesn't work

Good afternoon folks.

I've run into an issue with the code included in this question. I've seen this manner of excel VBA before, but unfortunately, it doesn't seem to work for me. I'm using Excel 2016, and I'm trying to navigate to an internal website and click on a link to start downloading a file and save it out to my desktop, but unfortunately, the code that I've seen that "clicks" the link doesn't seem to work.

Please see the code below:

'''

Sub Downloader()
    Dim Browser As Object
    Dim Website As String
    Dim LinkList As Object
    Set Browser = CreateObject("InternetExplorer.Application")
    Website = "http://website.com/thingamajig.html"
    With Browser
        .Visible = True
        .navigate Website
        For Each X In .document.getElementsByTagName("a")
            If X.Title = "Link to Change Reports" Then
                X.Click
                Exit For
            End If
        Next
    End With
End Sub

'''

Any help you can give on this matter would be incredibly appreciated.

Thanks!




Aucun commentaire:

Enregistrer un commentaire