Click an Hyperlink in Internet Explorer Using an Excel Macro

bpfsr used Ask the Experts™
Is there a general rule when writing a macro to clicking a hyperlink to move to the next page? For instance I am writing an macro that bring me to a page where I need to simply click a link to move on. Here is the link in the source code:

<table border="0" width="100%" cellspacing="0" cellpadding="4" align="center">
<tr><td valign="top">
<b class="h1">Choose a shipping address</b><br />Is the address you'd like to use displayed below? If so, click the corresponding "Ship to this address" button. Or you can <a href="#new-address">enter a new shipping address</a>.</td>
<td valign="top" align="right" width="200">

<br />

I want to click the a href="#new-address" link. Any help much apprecaited.

Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
You can have a link like:

<a href="#M4">Click Here</a>

The a place to go to:

<a href="m4.html">Here I am</a>

Hyperlinks, Anchors, and Links

In web terms, a hyperlink is a reference (an address) to a resource on the web.

Hyperlinks can point to any resource on the web: an HTML page, an image, a sound file, a movie, etc.

An anchor is a term used to define a hyperlink destination inside a document.

The HTML anchor element <a>, is used to define both hyperlinks and anchors.

We will use the term HTML link when the <a> element points to a resource, and the term HTML anchor when the <a> elements defines an address inside a document..


An HTML Link

Link syntax:

<a href="url">Link </a>  

The start tag contains attributes about the link.

The element content (Link text) defines the part to be displayed.

Note: The element content doesn't have to be text. You can link from an image or any other HTML element.


The href Attribute
The href attribute defines the link "address".

This <a> element defines a link to experts-exchange:

<a href="">Visit experts-exchange from here</a>  

The code above will display like this in a browser:

Visit experts-exchange from here


The target Attribute
The target attribute defines where the linked document will be opened.

The code below will open the document in a new browser window:

<a href=""
target="_blank">Visit experts-exchange from here</a>  



<a> Defines an anchor

Sudhakar A
Is that what you want?
Sub test()

    Dim IE As Object
    Dim IEaddress As String
    Set IE = CreateObject("InternetExplorer.Application")
    IEaddress = "file://youfile.html"
    IE.Visible = True
    IE.Navigate IEaddress
    While IE.Busy
    IE.Navigate "#new-address"

End Sub

Open in new window

I don't know why the question is going to be deleted.
Is that the author don't want?


trunqk43 - I posted the question for deletion because the first two answers were so completely off-base I just figured I had not asked the question properly. Since you seem to be more on mark if you want to object and have the question reinstated, that would be fine with me. As for your solution I think it is close but not quite; the hyperlink I am looking to activate is an external link, not a link to an internal file.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial