You are on page 1of 2

'To open Internate Explorer - Late Binding

--------------------------------------------
Sub BrowseToSite1()
Dim IE As Object
Set IE = CreateObject("InternetExplorer.Application")
IE.Visible = True
IE.navigate "www.google.com"
End Sub
============================================

'To open Internate Explorer - Early Binding


' Library required for Early Binding : Microsoft Internate Control
--------------------------------------------
Sub BrowseToSite2()
Dim IE As SHDocVw.InternetExplorer
'Dim IE As New SHDocVw.InternetExplorer
Set IE = New SHDocVw.InternetExplorer
IE.Visible = True
IE.navigate "www.google.com"
End Sub
============================================
'To open Internate Explorer - Importance of Waiting
'Waiting until Internate Explorer is Ready
--------------------------------------------
Sub BrowseToSite3()
Dim IE As SHDocVw.InternetExplorer
'Dim IE As New SHDocVw.InternetExplorer
Set IE = New SHDocVw.InternetExplorer
IE.Visible = True
IE.navigate "www.google.com"
Do While IE.readyState <> READYSTATE_COMPLETE
Loop
Debug.Print IE.LocationName, IE.LocationURL
End Sub
============================================
'Referring to the Elements of a Page or Refering to any elements
--------------------------------------------
Sub BrowseToSite5()
Dim IE As SHDocVw.InternetExplorer
'Dim IE As New SHDocVw.InternetExplorer
Set IE = New SHDocVw.InternetExplorer
IE.Visible = True
IE.navigate "en.wikipedia.org/wiki/Main_Page"
Do While IE.readyState <> READYSTATE_COMPLETE
Loop
Debug.Print IE.LocationName, IE.LocationURL
IE.document.forms("searchform").elements("search").Value = "VBA"
'To click on search option
IE.document.forms("searchform").elements("go").Click
End Sub
=============================================
'Document object model
'Preparing a More Complex Example
---------------------------------------------
Sub BrowseToSite6()
Dim IE As SHDocVw.InternetExplorer
'Dim IE As New SHDocVw.InternetExplorer
Set IE = New SHDocVw.InternetExplorer
IE.Visible = True
IE.navigate "en.wikipedia.org/wiki/Main_Page"
Do While IE.readyState <> READYSTATE_COMPLETE
Loop
Debug.Print IE.LocationName, IE.LocationURL
IE.document.forms("searchform").elements("search").Value = "VBA"
'To click on search option
IE.document.forms("searchform").elements("go").Click
End Sub
==============================================

You might also like