Closing an IE parent of a tab with VBA

Timonator

New Member
Joined
Jul 18, 2014
Messages
2
Hi all,

I am kind of stuck. I made a code which basically does some data pulling from html code from a web page. All code works fine, but I am using 2 instances of internet explorer to get to my data.
Code:
Dim ieMain As InternetExplorer


    Dim ie1 As InternetExplorerMedium
    Dim ie2 As InternetExplorerMedium
    Dim html1 As HTMLDocument
    Dim html2 As HTMLDocument


    Dim objSelectCollection As Object
    Dim objTableCollection As Object
    Dim objInputCollection As Object
    Dim objCollectionBanner As Object
    Dim objCollection As Object
    
    Dim objElement As Object
    Dim objLoginButton As Object
    Dim objSearchButton As Object
    Dim objClearButton As Object
    Dim MachineTypeFound As Boolean
    Dim loginScreen As Boolean
    
    Dim sBanner As String
    Dim i, J As Long
    Dim sequenceLink As String
    Dim MachineTypeHomeSheet As String
    
    Dim rowsMI, rowsSI As Integer
    Dim columnsMI, columnsSI As Integer
    
    ErrorDuringImport = False
    loginScreen = False


    Set ie1 = New InternetExplorerMedium
    Set ie2 = New InternetExplorerMedium
    
    ie1.Visible = True
    ie2.Visible = True
    
    ie1.Navigate "https://****.com"
    ie2.Navigate "https://****.com"

## bunch of code to grab what I need

'Code which does not work because because there are extra tabs
'ie1.quit
''ie2.quit

'Code which does not really work because I am trying to delete multiple entries and the shell shifts
'Dim Shell As Object
'    Dim IE As Object
'
'    Set Shell = CreateObject("Shell.Application")
'
'    For Each IE In Shell.Windows
'        If TypeName(IE.Document) = "HTMLDocument" Then
'            IE.Quit
'        End If
'    Next

The pages I go to for getting my info, run a script that opens a new tab within the same browser window. But my IE1 and IE2 only contain the first tabs of both IE windows. This means, if I quit them the extra tab stays open. How can I expand IE1 and IE2 to cover all the tabs that are in the IE window, so I can close them both?
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
Your commented out code to loop through Shell.Windows should close each IE tab in turn, of both IE windows. What do you mean by 'the shell shifts'?

Perhaps try adding before the loop:
Code:
    IE1.Stop
    IE2.Stop
 
Upvote 0

Forum statistics

Threads
1,224,586
Messages
6,179,711
Members
452,939
Latest member
WCrawford

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