Unable to connect IE

Pranesh

Board Regular
Joined
Jun 29, 2014
Messages
216
Hi All,


Im trying to connect a webpage using a code which i got from a website. When I tried with the default URL available in the code it worked perfectly.


I changed the URL to the URL which i need to open and i get the following error "Automation error The object invoked has disconnected from its client"


Can someone help me to fix this please.

Code:
Sub Automate_IE_Load_Page()
'This will load a webpage in IE
    Dim i As Long
    Dim URL As String
    Dim IE As Object
    Dim objElement As Object
    Dim objCollection As Object
 
    'Create InternetExplorer Object
    Set IE = CreateObject("InternetExplorer.Application")
 
    'Set IE.Visible = True to make IE visible, or False for IE to run in the background
    IE.Visible = True
   
 
    'Define URL
    'URL = "[URL]https://www.automateexcel.com/excel/[/URL]"
    
    'Navigate to URL
    IE.Navigate URL
    
 
    ' Statusbar let's user know website is loading
    Application.StatusBar = URL & " is loading. Please wait..."
 
    ' Wait while IE loading...
    'IE ReadyState = 4 signifies the webpage has loaded (the first loop is set to avoid inadvertently skipping over the second loop)
    
    Do While IE.READYSTATE = 4: DoEvents: Loop   'Do While
    Do Until IE.READYSTATE = 4: DoEvents: Loop   'Do Until
 
    'Webpage Loaded
    Application.StatusBar = URL & " Loaded"
 
    'Unload IE
    Set IE = Nothing
    Set objElement = Nothing
    Set objCollection = Nothing
    
End Sub
 

Some videos you may like

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.

Watch MrExcel Video

Forum statistics

Threads
1,099,784
Messages
5,470,743
Members
406,719
Latest member
ensbana

This Week's Hot Topics

Top