Results 1 to 8 of 8

Thread: [RESOLVED] Internet Explorer Tabs

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Aug 2011
    Location
    B.C., Canada
    Posts
    2,887

    Resolved [RESOLVED] Internet Explorer Tabs

    i am trying to open new tabs (which i can) and then close one of them (let's say the 2nd tab out of 5)

    and another question is how can i get the document of that 2nd tab? 2ndTab.Document ????

    would it be possible to launche new tab with some like this (i tried alot of methods did not get it to work)

    Code:
    Option Explicit
    
    Private IE As Object
    Private IETab As Object
    
    Private Sub Form_Load()
    Set IE = CreateObject("InternetExplorer.Application")
    IE.Visible = True
    IE.Navigate "www.google.com"
    
    Set IETab = IE.Navigate2("www.hotmail.com", 2048)
    End Sub
    i know this will never work.. but how can i do this? is there a way

    i would like to be able to navigate to where i want with any tab i want

  2. #2
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Internet Explorer Tabs

    you can do this, but you need to find some way to identify each tab, possibly if you get the first tab, the others will be consecutive, but i have never tested if this is the case

    you can use a shell object to find ie windows then automate each window, but the index of ie windows will change if explorer windows are opened or closed, as explorer windows are always first in the shell windows collection, and of course there maybe multiple ie instances as well

    note each tab is a separate shell window
    Last edited by westconn1; Aug 13th, 2012 at 06:31 AM.
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  3. #3

    Thread Starter
    PowerPoster
    Join Date
    Aug 2011
    Location
    B.C., Canada
    Posts
    2,887

    Re: Internet Explorer Tabs

    use a shell object to find ie windows
    thanks i will look into it

  4. #4

    Thread Starter
    PowerPoster
    Join Date
    Aug 2011
    Location
    B.C., Canada
    Posts
    2,887

    Re: Internet Explorer Tabs

    after your suggestion i have looked into it you can use either

    Code:
    ShDocVw.ShellWindows 'This requires reference to Microsoft Internet Controls and you can use withevents (if needed)
    'or
    CreateObject("Shell.Application") 'This does NOT require any reference but cannot use withevents
    and code

    Code:
    Private Declare Sub Sleep Lib "kernel32.dll" (ByVal dwMilliseconds As Long)
        
    Private Google As Object
    Private Bing As Object
    Private Yahoo As Object
    Private IEOpened As Boolean
    
    
    Private Sub LoadSearchEngine()
    Dim Shell_Windows As Object
    Dim IE As Object
        
        IEOpened = False
        Set Shell_Windows = CreateObject("Shell.Application").windows
    
        For Each IE In Shell_Windows
            If IE.Application = "Windows Internet Explorer" And Not IE.locationname = vbNullString Then
              IEOpened = True
              List1.AddItem IE.locationname
            End If
        Next
    
    If Not IEOpened Then
     GoTo CreateWindows
    ElseIf MsgBox("Please close all Internet Explorer windows, would you like me to close them all for you and load the search websites?", vbExclamation Or vbYesNo, "Opened Windows Found") = vbYes Then
      Shell "cmd.exe /c TASKKILL /IM iexplore.exe /F"
      Sleep 2000
      GoTo CreateWindows
    End If
    
    Exit Sub
    
    CreateWindows:
     Set IE = CreateObject("InternetExplorer.Application")
       IE.navigate "www.google.com"
       IE.navigate2 "www.bing.com", 2048 '2048 create new tab
       IE.navigate2 "www.yahoo.com", 2048 '2048 create new tab
       
    Sleep 2000
    
        For Each IE In Shell_Windows
            If IE.Application = "Windows Internet Explorer" And Not IE.locationname = vbNullString Then
              If InStr(1, IE.locationname, "Google") <> 0 Then
                Set Google = IE
              ElseIf InStr(1, IE.locationname, "Bing") <> 0 Then
                Set Bing = IE
              ElseIf InStr(1, IE.locationname, "Yahoo") <> 0 Then
                Set Yahoo = IE
              End If
            End If
        Next
    
       Bing.Visible = True
       Google.Visible = True
       Yahoo.Visible = True
    
    End Sub
    
    
    
    
    Private Sub Command1_Click()
    'Control Google tab here (navigate,document,visible,left,top,width,height ETC)
    Google.navigate "www.hotmail.com"
    End Sub
    
    Private Sub Command2_Click()
    'Control Bing tab here (navigate,document,visible,left,top,width,height ETC)
    Bing.navigate "www.hotmail.com"
    End Sub
    
    Private Sub Command3_Click()
    'Control Yahoo tab here (navigate,document,visible,left,top,width,height ETC)
    Yahoo.navigate "www.hotmail.com"
    End Sub
    
    Private Sub Form_Load()
    LoadSearchEngine
    End Sub
    Attached Files Attached Files

  5. #5
    PowerPoster
    Join Date
    Jul 2006
    Location
    Maldon, Essex. UK
    Posts
    6,334

    Re: [RESOLVED] Internet Explorer Tabs

    @Max - I've been following this thread with interest. For the life of me I could not get the 'new tab' piece to work unless I specifically cast the '2048' as a Long (ie 2048&) in the Navigate statement. As for trying to obtain the 'Document' object from IE for each Tab - Getting the first one was simple but as for the others - I gave up eventually.

    Googling around I discovered that there's an undocumented interface for handling Tabs in IE which the Guys from Chrome have (or might have) implemented.

  6. #6
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: [RESOLVED] Internet Explorer Tabs

    For the life of me I could not get the 'new tab' piece to work unless I specifically cast the '2048' as a Long (ie 2048&) in the Navigate statement.
    i did not have that problem at all, worked no problem

    nice implementation for working with shell windows,
    where did you find the parameter value for navigate?
    think i found the answer to that
    navOpenInNewWindow = 0x1,
    navNoHistory = 0x2,
    navNoReadFromCache = 0x4,
    navNoWriteToCache = 0x8,
    navAllowAutosearch = 0x10,
    navBrowserBar = 0x20,
    navHyperlink = 0x40,
    navEnforceRestricted = 0x80,
    navNewWindowsManaged = 0x0100,
    navUntrustedForDownload = 0x0200,
    navTrustedForActiveX = 0x0400,
    navOpenInNewTab = 0x0800,
    navOpenInBackgroundTab = 0x1000,
    navKeepWordWheelText = 0x2000,
    navVirtualTab = 0x4000,
    navBlockRedirectsXDomain = 0x8000,
    navOpenNewForegroundTab = 0x10000
    from http://msdn.microsoft.com/en-us/libr...=vs.85%29.aspx
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  7. #7

    Thread Starter
    PowerPoster
    Join Date
    Aug 2011
    Location
    B.C., Canada
    Posts
    2,887

    Re: [RESOLVED] Internet Explorer Tabs

    At doogle where is that undocumented website? I have been looking and looking never found an answer for controlling tabs but i got it to work yesturday thanks to westconn and my researches

    At westconn that is exactly where i found the parameters

    In the end i am happy with what i finally got working hopefully this will anwser a couple questions in the futur

  8. #8
    PowerPoster
    Join Date
    Jul 2006
    Location
    Maldon, Essex. UK
    Posts
    6,334

    Re: [RESOLVED] Internet Explorer Tabs

    @Max: Sorry for the delay. I couldn't find the exact page again but I did trip over this: https://developer.chrome.com/extensions/tabs.html

    I've not got Chrome installed but it looks as if it can be automated and they have 'facilities' to manage Browser Tabs programatically.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width