Click here to Skip to main content
15,850,103 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
                If TypeOf (IEx.Document) Is HTMLDocument Then
                    IE = IEx
                    CurrentDoc = IE.Document
                    CurrentDoc.url = ""
                End If
                i = i + 1
            Catch ex As Exception
            End Try
    End Sub



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 = ""
            End If
    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.
Updated 21-Jul-10 4:34am
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:[^]

And take a look here:[^]

Good luck!
Share this answer
rus204 21-Jul-10 11:29am    
ah.. thanks.
but my Code 1 is same thing ` `
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