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

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.

Forum statistics

Threads
1,214,606
Messages
6,120,478
Members
448,967
Latest member
visheshkotha

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