Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VB8.0 VB9.0 VB.NET
I want to change the IE tab URL.
 
Code 1:
 
Imports mshtml
 
Public Class Form1
 
~~~~~~~~~~~~~~~~~~~
 
    Dim WithEvents IE As SHDocVw.InternetExplorer
    Dim WithEvents CurrentDoc As HTMLDocument
 
    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        Dim SWs As New SHDocVw.ShellWindows
        Dim IEx As SHDocVw.InternetExplorer
        Dim i As Integer = 1
        Timer1.Enabled = False
        For Each IEx In SWs
            Try
                If TypeOf (IEx.Document) Is HTMLDocument Then
                    IE = IEx
                    CurrentDoc = IE.Document
                    CurrentDoc.url = "http://google.com"
                End If
                i = i + 1
            Catch ex As Exception
                MessageBox.Show(ex.Message)
            End Try
        Next
    End Sub
 
~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
And
 
Code 2:
Imports SHDocVw
 
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim browser As SHDocVw.InternetExplorer
        Dim myLocalLink As String
        Dim myDoc As mshtml.IHTMLDocument
        Dim shellWindows As SHDocVw.ShellWindows = New SHDocVw.ShellWindows()
        Dim filename As String
        For Each ie As SHDocVw.InternetExplorer In shellWindows
            filename = System.IO.Path.GetFileNameWithoutExtension(ie.FullName).ToLower()
            If filename = "iexplore" Then
                browser = ie
                myDoc = browser.Document
                myLocalLink = myDoc.url
                myDoc.url = "http://www.google.com"
                'MessageBox.Show(myLocalLink)
            End If
        Next
    End Sub
 
Under both Code 1 and Code 2 is going to move IE's URL.
 
But.. All tabs navigate to the URL(google).
 
I want to change the active tab's URL.
Posted 21-Jul-10 4:21am
rus204687
Edited 21-Jul-10 4:34am
Dalek Dave432.9K
v2
Comments
Dalek Dave at 21-Jul-10 9:35am
   
Edited for highlighting code.

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

IE now creates a new process for each tab. By traversing all IE's will therefore go by all tabpages.
 
Maybe this link can help:
 
http://social.msdn.microsoft.com/Forums/en-US/vbgeneral/thread/60c6c95d-377c-4bf4-860d-390840fce31c[^]
 
And take a look here:
 
http://www.eggheadcafe.com/community/aspnet/2/10112922/how-to-get-current-active-tab-handle-in-an-ie7-window-using-c.aspx[^]
 
Good luck!
  Permalink  
Comments
rus204 at 21-Jul-10 11:29am
   
ah.. thanks.
but my Code 1 is same thing ` http://social.msdn.microsoft.com/Forums/en-US/vbgeneral/thread/60c6c95d-377c-4bf4-860d-390840fce31c `
..
I already saw that
E.F. Nijboer at 21-Jul-10 12:47pm
   
And the other link? There is some code using the accessibility api, maybe this could help.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



Advertise | Privacy | Mobile
Web01 | 2.8.1411022.1 | Last Updated 1 Aug 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100