1. Welcome to Chandoo.org Forums. Short message for you

    Hi Guest,

    Thanks for joining Chandoo.org forums. We are here to make you awesome in Excel. Before you post your first question, please read this short introduction guide. When posting or responding to questions please remember our values at Chandoo.org are: Humility, Passion, Fun, Awesomeness, Simplicity, Sharing Remember that we have people here for whom English is not there first language and we need to allow for this in our dealings.

    Yours,
    Chandoo
  2. Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  3. When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

VBA code to click a link.

Discussion in 'VBA Macros' started by chris heath, Nov 8, 2018.

  1. chris heath

    chris heath New Member

    Messages:
    2
    Hi Guys,

    Please can anyone help with the code to click the link in the following:

    <A style="COLOR: black" href="../track/detail.do?ID=2473543">2473543</A>

    The ID number at the end of the link will be changing,

    (I found when I copied the ID from another excel sheet the format it copied it in will not work as a direct link to the page a I need unlike is I type it in but I cant see anything different on the format options.

    so can someone help with getting a code to click the link that is above or a way to change the format so its the same as if I typed it?

    Thanks :)
  2. chris heath

    chris heath New Member

    Messages:
    2
    >>> use CODE -tags <<<
    Code (vb):

    Private Sub Button2()
    Dim ie As InternetExplorerMedium
    Dim BlankFound As Boolean
    Dim x As Long

      If Cells(2, 6) = "" Or Cells(2, 6) = "Call ID" Then
      Exit Sub
      End If

      Set ie = New InternetExplorerMedium
      ie.Visible = True

    ie.Navigate "https://eu.nissan.biz/nfit/calls/open/openCalls.do?advanceSearch=display:none"
    Do While ie.Busy Or ie.ReadyState <> 4
      DoEvents
    Loop

    ie.Document.all("ID").Value = Cells(2, 6)
    With ie.Document
      Set elems = .getElementsByTagName("input")
      For Each e In elems
      If (e.getAttribute("value") = "Search") Then
      e.Click
      Exit For
      End If
      Next e
      End With

      Do While ie.Busy Or ie.ReadyState <> 4
      DoEvents
    Loop

    Set tags = ie.Document.getElementsByTagName("a")
    For Each tagx In tags
      If tagx.innerText = Cells(2, 6) Then
      tagx.Click
      Exit For
      End If
    Next

    'ie.Navigate "https://eu.nissan.biz/nfit/calls/track/detail.do?ID=" & Cells(2, 6)

      Do While ie.Busy Or ie.ReadyState <> 4
      DoEvents
    Loop

    ie.Document.getElementByid("a7").Click
    'Application.Wait (Now + TimeValue("0:00:03"))
    ie.Document.all("inot").Value = "Auto Close Tool"
    'Application.Wait (Now + TimeValue("0:00:03"))
    ie.Document.all("feedback_required").Click
    'Application.Wait (Now + TimeValue("0:00:03"))
    With ie.Document
      Set elems = .getElementsByTagName("input")
      For Each e In elems
      If (e.getAttribute("value") = "Save") Then
      e.Click
      Exit For
      End If
      Next e
      End With

    ie.Quit

    End Sub
     

    Cell(2,6) is where I full the ID number from
    Last edited by a moderator: Nov 8, 2018

Share This Page