Internet explorer object (1 Viewer)

CedarTree

Registered User.
Local time
Today, 01:56
Joined
Mar 2, 2018
Messages
404
I'll admit upfront i don't get the IE object.
What I'm trying to do is open one web page and then open a 2nd page (as a 2nd tab).
Using Access 2016 and IE11 in a corporate environment.
Here's my code so far:

Code:
ie.Navigate2 "msnbc.com", 2 + 65536
Pause (2) [calls a function that waits 2 seconds]
ie.Navigate2 "cnn.com", 2 + 65536 <-- at this point, VBA acts like the IE object disappeared, so I use a "get" function to find the IE object.

Trouble is, IE always opens up 2 windows. I'd love for it instead to open up 2 tabs. Suggestions?
 

CedarTree

Registered User.
Local time
Today, 01:56
Joined
Mar 2, 2018
Messages
404
I've tried a few things and IE just acts strangely. Just hard to get a consistent and reliable way to open up 2 websites, one after another.
 

moke123

AWF VIP
Local time
Today, 01:56
Joined
Jan 11, 2013
Messages
3,852
I found this which opens 3 tabs but it runs all at once.

Code:
Set IE = CreateObject("InternetExplorer.Application")

    With IE
        .Navigate "https://amazon.com" '1st tab
        .Navigate "https://flipkart.com", CLng(2048)  '2nd
        .Navigate "https://snapdeal.com", CLng(2048) '3rd
        .Visible = True
   End With

The thing to note is the CLng(2048) which must be a switch to tell IE to use a new tab.

That lead me here - https://docs.microsoft.com/en-us/previous-versions//dd565688(v=vs.85)?redirectedfrom=MSDN

Edit:

Got this to work

Code:
Option Compare Database
Option Explicit

Dim IE As Object

Sub Test()
RunIE "https://google.com"
End Sub


Sub RunIE(U As String)

If Not IE Is Nothing Then

    With IE
        .Navigate U, CLng(2048)
        .Visible = True
    End With

Else

Set IE = CreateObject("InternetExplorer.Application")

    With IE
        .Navigate U
        .Visible = True
    End With

End If

End Sub

2048 opens the tab on top and 4096 opens the tab behind the open tab
You may need a procedure to set the global object to nothing.
 
Last edited:

Users who are viewing this thread

Top Bottom