Posts Tagged ‘Internet’

Opening URL @ new tab in Internet Explorer: VBA

Posted: September 11, 2013 by Theodoulus in Excel, General Tips, VBA
Tags:

Problem Statement: Suppose, we have an array of URLs and we need to open them one by one. By looping over all the URLs on the same tab at internet explorer, we need to check the internet explorer is in LOADED or LOADING state. If the explorer is in loading state, it may give an error. And by default, the URL will be opened on the same tab.

So the process of opening URL on the same tab will be lengthy in terms of Coding, and processing time.

Solution:

We can use different tabs of the Internet Explorer so that we would not have to check the READYSTATE and to REFRESH the tab again and again. The example is given below:

Option Explicit

Sub OpenURLOnNewTab()

    Dim lngC As Long
    Dim strUrl  As String
    Dim ieObj   As InternetExplorer

    Set ieObj = New InternetExplorer
    ieObj.Visible = True
    strUrl = "https://usefulgyaan.wordpress.com/"       'We have taken one URL but you can take an array of URLs

    For lngC = 1 To 100
        ieObj.Navigate2 strUrl, 2048            '2048 is to open the URL on the new tab
    Next lngC

End Sub