Click here to Skip to main content
15,867,330 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
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
Updated 21-Jul-10 3:34am
v2
Comments
Dalek Dave 21-Jul-10 9:35am    
Edited for highlighting code.

1 solution

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!
 
Share this answer
 
Comments
rus204 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 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)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900