Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > Knowledge Base > Code Library > Listing Internet Explorer Windows


Reply
 
Thread Tools Display Modes
  #1  
Old 12-10-2005, 10:55 AM
herilane's Avatar
herilane herilane is offline
Unashamed geek

Retired Moderator
* Expert *
 
Join Date: Jul 2003
Location: London, England
Posts: 8,988
Default Listing Internet Explorer Windows

Internet Explorer supports automation, but GetObject isn't very useful for getting hold of existing IE windows - partly because IE windows are based on the same class as Windows Explorer windows, and partly because you can't specify which window you want based on a path name, as you can for other applications. (Not that I know of, at least.)

This simple procedure avoids GetObject and instead loops through all open IE and WE windows. You can use LocationURL and/or LocationName to find the IE window that you require. Not my own invention, but I find it very useful and underpublicized.

This requires a reference to Microsoft Internet Controls and to Microsoft Shell Controls and Automation.
Code:
Sub ListShellWindows() 'Get all currently open IE and Explorer windows 'For IE windows, get location. For WE windows, get path. Dim objShell As Shell Dim objIE As InternetExplorer Dim objExplorer As ShellFolderView Dim obj As Object Set objShell = New Shell For Each obj In objShell.Windows If TypeName(obj.Document) = "HTMLDocument" Then Set objIE = obj Debug.Print objIE.LocationURL Else Set objExplorer = obj.Document Debug.Print objExplorer.FocusedItem.Path End If Next obj End Sub
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Advertisement:

Powered by liquidweb