IE Automation VBA - method 'document' of object 'iwebbrowser2' failed

gagerson

New Member
Joined
Jul 14, 2015
Messages
1
Hi,

As first I need to say I'm very new to VBA. I have took upon myself to build an automation for IE for my departament which when done will go to the website and put reference number in and search for certain client info.
I got stuck on very first hurdle and been researching internat for past 2 days to help me with problem but to no avail.

This is my code so far: (I have changed URL as its data sensitive):
Rich (BB code):
Sub gotosite()
Dim IE As Object
Set IE = CreateObject("InternetExplorer.Application")

With IE
    IE.Visible = True
    IE.Silent = True
    IE.navigate "url.com"
    
        Do While IE.Busy
        Application.Wait DateAdd("s", 1, Now)
    Loop

End With



IE.document.getElementById("txtPolicyNumber").Value = "12345"




End Sub

The one in bold is where it crashes and gives me method 'document' of object 'iwebbrowser2' failed error. Help please!
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).

Forum statistics

Threads
1,215,327
Messages
6,124,276
Members
449,149
Latest member
mwdbActuary

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