By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,300 Members | 1,795 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,300 IT Pros & Developers. It's quick & easy.

Find a specific window and open a URL.

P: n/a
I need to use an existing IE window which already has a specific url and
re-use that window for a new URL.

Example:

One open IE window has the following in its Address Bar:

http://www.vbcity.com/forums/search.asp?mode=doit

The window title is:

vbCity/DevCity.Net Forums :: Search for - search find window- Microsoft
Internet Explorer

I want to re-use this window to display a new URL. My code to find this
window is:

Friend Sub FindWindowHwnd(ByVal strTitle As String)
' Get the target's window handle.
Dim target_hwnd As Double = FindWindow(vbNullString, strTitle & "*")
If (target_hwnd = 0) Then
MessageBox.Show("Error finding target window handle")
Exit Sub
End If
MessageBox.Show(target_hwnd)
End Sub

I will call the window like this:

Call FindWindowHandle.FindWindowHwnd("VBCity")

So how do I use the window's Hwnd to send it a new URL?

--
|
+-- Thief_
|
Nov 21 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Thief,

Are you not busy on the client computer?

That is mostly done by JavaScript and very seldom with VBS.

I hope this helps,

Cor
Nov 21 '05 #2

P: n/a
What are you talking about?? Who mentioned VBS- this is a VB.Net newsgroup!

--
|
+-- Thief_
|

"Cor Ligthert [MVP]" <no************@planet.nl> wrote in message
news:uZ*************@TK2MSFTNGP11.phx.gbl...
Thief,

Are you not busy on the client computer?

That is mostly done by JavaScript and very seldom with VBS.

I hope this helps,

Cor

Nov 21 '05 #3

P: n/a
"Thief_" <th****@hotmail.com> schrieb:
I need to use an existing IE window which already has a specific url and
re-use that window for a new URL.


Add a reference to "Microsoft Internet Controls", then use the code below:

\\\
' Written by Herfried K. Wagner [MVP].
Public Function ReplaceInternetExplorerUrl( _
ByVal OldUrl As String, _
ByVal NewUrl As String, _
Optional ByVal ReplaceFirstInstanceOnly As Boolean = False _
) As Integer
Dim i As Integer
For Each IE As InternetExplorer In New ShellWindows
If IE.LocationURL = OldUrl Then
IE.Navigate(NewUrl)
i += 1
If ReplaceFirstInstanceOnly Then
Exit For
End If
End If
Next IE
Return i
End Function
///

Usage:

\\\
MsgBox(ReplaceInternetExplorerUrl("http://www.google.de/",
"http://search.msn.com/"))
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.