title: vba intercept internet explorer link click
body: <p>I'm using excel 2010, vba. I have a web page at work - which I created, and when the user clicks on a link, i want to intercept that link, and run vba (not the javascript onclick event).   ie bind the onclick event to VBA function or sub if possible. Some sites hint it can be done. Question for an automation guru. Note i do not want to click the link thru automation (the below code does this) I want the user to click and the VBA intercept the click ( note, i don't want to replace the javascript with more js I want to call VBA). I'm using the InternetExplorer object but might need to use another ie object or library reference as you advise.</p>
  
  <p>The below code (example) opens the www's first web page and clicks on the link. I want to intercept this click and run vb code.</p>
  
  <pre><code>Dim ie As InternetExplorer
  Set ie = New InternetExplorer
  sURL = "http://info.cern.ch/hypertext/WWW/TheProject.html" ' www's first web page
  
  ie.Navigate sURL
  ie.Visible = True
  Do While ie.Busy
      DoEvents
  Loop
  Set oForm = ie.Document.getElementsByName("0") ' worlds first ever anchor/ hyper link
  Set oLink = oForm.Item(0)
  
  'oLink.onclick = ' set/add to VBA function to replace/set javascript onlclick event ie. to intercept click
  
  oForm.Item(0).Click ' run vba code to display msgbox "hello World" not navigate
  </code></pre>