• 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...

  • 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.

chris heath

New Member
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 :)
 
>>> use CODE -tags <<<
Code:
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:
Back
Top