
redirect web page from vb if I have window handle
Hello,
Thank you for using the Microsoft Newsgroups.
It's not needed to get the window handle of IE. Instead, the ShellWindows
collection is described in the Internet Client SDK as follows: The
ShellWindows object represents a collection of the open windows that belong
to the shell. In fact, this collection contains references to Internet
Explorer as well as other windows belonging to the shell, such as the
Windows Explorer.
So, you can get a reference to a specific instance of InternetExplorer.
Then, you can call its Navigate method.
The following code enumerate all InternetExplorer and navigate to your URL.
To use the following code, please add a reference to "Microsoft Internet
Controls" (Shdocvw.dll) and "Microsoft HTML Object Library" (Mshtml.dll) to
the Visual Basic project:
Dim SWs As New SHDocVw.ShellWindows
Dim IE As SHDocVw.InternetExplorer
Private Sub Form_Load()
Dim Doc
For Each IE In SWs
Set Doc = IE.Document
If TypeOf Doc Is HTMLDocument Then
'if this is an HTML page, navigate.
'you can have your condition checking for get a specific IE
IE.Navigate URL
End If
Next
End Sub
Please feel free to let me know if you have any questions.
Best Regards,
Kenny Zhou
Microsoft Support
This posting is provided "AS IS" with no warranties, and confers no rights.
Got .Net? http://www.gotdotnet.com