Q:

How to select IE tabs after simulate click

I'm making a simple script which can open a site, find a button, click on it (open a new tab) and find data on the new tab. I'm blocked in a dump point : how can i access the data on the new tab ? 
thanks a lot !
Sub testWebOpenTabAndFocus()    
    Dim i As Long
    Dim IE As Object
    Dim objElement As Object
    Dim objCollection As Object

    ' open new IE window
    Set IE = CreateObject("InternetExplorer.Application")
    IE.Visible = True

    ' Send the form data To URL As POST binary request
    IE.navigate "somesite.com"

    '..... some code to search about a button

    objElement.Click    ' click button to load a new tab

    ' Wait while IE re-loading...
    While IE.Busy
            DoEvents
    Wend

    ' finding the new tab with Windows(x)

    Set objShell = CreateObject("Shell.Application")
    IE_count = objShell.Windows.Count
    For x = 0 To (IE_count - 1)
        On Error Resume Next    ' sometimes more web pages are counted than are open
        my_title = objShell.Windows(x).Document.Title
        If my_title Like "*Analysis Application*" Then 
            Set IE = objShell.Windows(x) 'this is my new tab
        End If
    Next

    'Some code to be runned on the new tab
    'but its not working because it still has the focus on previous tab

    'Unload IE
    Set IE = Nothing
    Set objElement = Nothing
    Set objCollection = Nothing
End Sub

A:

Try to replace below code part in your above code may help to fix the issue.
Set objShell = CreateObject("Shell.Application")
    IE_count = objShell.Windows.Count
    For x = 0 To (IE_count - 1)
        On Error Resume Next

        ' sometimes more web pages are counted than are open
         If x.Name = "Internet Explorer" And TypeName(x.document) = "HTMLDocument" Then
        my_title = objShell.Windows(x).document.Title
        Debug.Print (my_title)
        If my_title Like "*Analysis Application*" Then
            Set IE = objShell.Windows(x) 'this is my new tab
        End If
         End If
    Next

If issue persist than try to provide detailed information like on which line you are getting error or you stuck there with error message may give us more idea about the issue.

