VBA – Opening a web page on IE

Despite the fact that it is a very old issue, practicing is the best way to remember a hint. And the hint is, opening a web page through VBA code. Take a look at code below:

Private Sub OpenPage()
    Dim browser As Variant
    Set browser = CreateObject(“InternetExplorer.Application”)
    browser.Navigate (“www.google.com”)
    browser.Visible = True
End Sub

So far so good, but the best thing in the code above is, the Internet Explorer is under your control! You can have access to all webpage data through the Internet Explorer object’s properties. Of course, you can play a bit with some simple properties, like:

Private Sub DrawingIn_Click()
    Dim browser As Variant
    Set browser = CreateObject(“InternetExplorer.Application”)
    browser.Navigate (“www.google.com”)
    browser.StatusBar = False
    browser.Toolbar = False
    browser.Visible = True
    browser.Resizable = False
    browser.AddressBar = False
End Sub

Enjoy!

Comentários

comentários