Controlling IE no longer works in different Excel version

castertroy

New Member
Joined
Mar 6, 2010
Messages
32
Hi,

I had a code that runs fine in Excel 2000 but now I am on Excel 2003 when I click on the button to start the macro nothing happens. I have checked the references and the Microsoft Internet Controls and HTML object boxes are ticked. Here is the code:

Code:
Sub Macro1()
'
' Macro1 Macro
' Macro recorded 09/03/2011 by X'

Dim Shell As Object
    Dim IE As Object
   Set IE = CreateObject("internetexplorer.application")
Dim oIE As Object
    Dim oForm As Object
    Dim objShellWins As SHDocVw.ShellWindows
    Dim objIE As SHDocVw.InternetExplorer
    Dim objDoc As Object
    Dim usdURL As String
    Dim myUSD As String
    Dim ws As Worksheet
Set ws = Worksheets("Sheet1")
    
    Set Shell = CreateObject("Shell.Application")
    
    
    For Each IE In Shell.Windows
    If IE.LocationURL = "[URL]http://www.google.co.uk/[/URL]" Then
    
            IE.Visible = True
            
                Do While IE.Busy: DoEvents: Loop
    Do While IE.ReadyState <> 4: DoEvents: Loop
            
            
    
    
     
    End If
    Next
'
End Sub

If I use an older PC here it works fine on Windows/Excel 2000 but for some reason it no longer runs. Does anyone have any ideas how to rectify this?

Thanks
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
Code looks ok to me - have you tried stepping through it?
 
Upvote 0
Thanks, I have tried stepping through it. It highlights the line...

Code:
Set IE = CreateObject("internetexplorer.application")


... but doesn't actually give an error message.
 
Upvote 0
What happens when you press f8 on that line then?
 
Upvote 0
It highlights the line in yellow. If I press F8 again it skips to the line...

Code:
Set ws = Worksheets("Sheet1")

... and also highlights in yellow.

I've noticed I am now on IE7 instead of IE6 which I used to use as well. Not sure if that makes any difference.
 
Upvote 0
keep pressing f8 until either an error occurs or the sub ends (that's what I meant by stepping through the code). I am assuming that you have Google set up as your home page?
 
Upvote 0
No error occurs and when I keep pressing F8 it ends up looping between the line ...

Code:
If IE.LocationURL = "[URL]http://www.google.co.uk/[/URL]" Then

and the lines....

Code:
End If
    Next

Google is not set up as my homepage but I have an open instance of IE which is already navigated to it.
 
Upvote 0
What are you expecting it to do then if you already have an open visible instance with Google loaded?
 
Upvote 0
Sorry, I have a process whereby an online form gets completed based on data in Excel. The old code doesn't work with my new setup on Excel 2003 and IE7.

I am using the google homepage here as an example of how Excel no longer navigates to the open instance of Google.

Once I can get Excel to navigate to the open instance of Google I should be ok. I can go back downstairs to my old PC, open the exact same document and bingo it flicks to google. Up here, it just pauses for a second then... nothing.
 
Upvote 0
Why do you need to navigate to it rather than just manipulating it?
 
Upvote 0

Forum statistics

Threads
1,214,932
Messages
6,122,334
Members
449,077
Latest member
Jocksteriom

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