Navigate in ie from excel using source code in web page

chrisbrocco

Board Regular
Joined
Mar 31, 2005
Messages
82
Hi all, i am trying to make excel open a web page then naviagte to a link. I know how to do this if the link has the same address all the time using

Set ie = CreateObject("InternetExplorer.Application")

With ie
.Visible = True
' Go to web page
.navigate "http://www.google.co.uk/imghp?hl=en&tab=wi"

Do Until .readyState = 4
DoEvents
Loop

but how could I navigate to a link which continually changes.

for example on a web page the link always shows "report", but the actual address may changes say every hour.

Is there a way to navigate to what ever address sits behind "report"
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
Chris

Is the URL you've posted 'genuine'?

If it is I'll try and take a look at it.

Also you say the link always displays as Report?
 
Upvote 0
Chris

I could help with this, if you posted 'real' URL's.

Without them I can only really give general advice.

For example here's a piece of code that I helped another member with.
Code:
Sub Test()
Dim lnk
    Set ie = CreateObject("InternetExplorer.Application")
    With ie
        .Visible = True
        .Navigate "http://www.nu.nl/"
        Do Until .ReadyState = 4: DoEvents: Loop
       
        Set doc = ie.document
    
        Open "C:\TestHTML.txt" For Output As #1
            For Each lnk In doc.links
                Print #1, lnk
            Next lnk
        Close #1
    End With
    
End Sub
I realise this isn't exactly what you are looking for but it might give you some ideas.
 
Upvote 0
Chris

What the posted code does is create a text file containing all the links on the webpage.

This part of it loops through all the links and writes the to the text file.
Code:
For Each lnk In doc.links
     Print #1, lnk
Next lnk
Hopefully that will give you some ideas, but like I said it's hard to help with this sort of thing without valid URLs.

You could probably put some sort of If in the loop to find the link you want and then navigate to it.

Here's a <a href="http://msdn.microsoft.com/library/default.asp?url=/workshop/author/dhtml/reference/dhtml_reference_entry.asp
">link</a> that might help.
 
Upvote 0
ok I have an idea. if I change it to:

Open "C:\TestHTML.xls" For Output As #1

the link I want is in cell A1

what would be the code to navigate to C:\TestHTML.xls cell A1

many thanks again
 
Upvote 0
chris

I'm still unsure what you exactly want to do.

Can you explain further?
 
Upvote 0
I want to goto web page A, and navigate within this web page to link B which addess changes (due to updates) every hour or so.

As the address changes every hour I cant use

With ie
.Visible = True
' Go to web page
.navigate "http://www.B.co.uk/"

because an hour later it would be http://www.B1.co.uk/

so I need a way to find the address ( as your code does) and then navigate to the new address in cell A1

The code you have sent works perfectly, all I need to do now is:

k = "C:\TestHTML.xls cell A1" (which I now is wrong)

With ie
.Visible = True
' Go to web page
.navigate K

And this should work

any ideas how to write k = "C:\TestHTML.xls cell A1" in the correct format
 
Upvote 0

Forum statistics

Threads
1,214,541
Messages
6,120,110
Members
448,945
Latest member
Vmanchoppy

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top