ProgrammingMSAccess.com

Learn about Developers Group
Join Developers Group
Order SPAM Blocker
Free Stuff
Guest Book
.NET Resources
SQL Server Resources
Favorites
Technical Support
Books & DVDs by Webmaster
Articles, tutorials, & more
FAQs
Product Reviews
Samples
Prior Newsletters
Contact Us
Home
 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

A set of vba Procedures that PROGRAMMATICALLY MANIPULATE INTERNET EXPLORER SESSIONS.  OPEN AT LEAST TWO INTERNET EXPLORER SESSIONS BEFORE RUNNING THE PROCEDURE WITH ONE POINTING AT WWW.PROGRAMMINGMSACCESS.COM AND THE OTHER AT WWW.MICROSOFT.COM.  ALSO, ADD REFERENCES TO THE MICROSOFT INTERNET CONTROLS LIBRARY AND THE MICROSOFT HTML OBJECT LIBRARY. SAME APPROACH WORKS FOR vb AND VB.NET.

Sub ManipulateIESessions()

'Declare Browser Windows Collection,
'an enumerator for collection, and a
'variable with a HTMLDocument object
Dim bwc1 As New SHDocVw.ShellWindows
Dim ie1 As SHDocVw.InternetExplorer
Dim doc1 As MSHTML.HTMLDocument

'Report count of items in the collection
'Debug.Print bwc1.Count

ReportIESessions

'Loop through collection items, print
'document title, and toggle navigation
'between ProgrammingMSAccess.com and
'Microsoft.com, or close window if not
'already at either URL
For Each ie1 In bwc1
    Set doc1 = ie1.Document
    If TypeOf doc1 Is HTMLDocument Then
        Debug.Print doc1.title
        If doc1.title = "ProgrammingMSAccess.com" Then
            ie1.Navigate "http://www.microsoft.com"
        ElseIf doc1.title = "Microsoft Corporation" Then
            ie1.Navigate "http://www.programmingmsaccess.com"
            'ie1.Visible = False
        Else
            ie1.Quit
            CompleteIESessions
            ReportIESessions
            Exit Sub
        End If
    End If
Next

End Sub

Sub ReportIESessions()

Dim bwc1 As New SHDocVw.ShellWindows
Dim int1 As Integer
Dim ie1 As SHDocVw.InternetExplorer

Debug.Print "Total IE sessions: " & bwc1.Count
For int1 = 0 To bwc1.Count - 1
    Set ie1 = bwc1.Item(int1)
    Debug.Print "IE session " & int1
    Debug.Print vbTab & "Title: " & _
        ie1.LocationName
    Debug.Print vbTab & "URL: " & _
        ie1.LocationURL
    Debug.Print vbTab & "Visible: " & _
        ie1.Visible
Next int1

End Sub

Sub CompleteIESessions()

Dim bwc1 As New SHDocVw.ShellWindows
Dim myie As SHDocVw.InternetExplorer

For Each myie In bwc1
Do Until myie.ReadyState = READYSTATE_COMPLETE
Loop
Next

End Sub

Want to understand  Microsoft Access so that you can program it to do more tasks like this?  Get Programming Microsoft Office Access 2003 by Rick Dobson from Microsoft Press.  Learn more about the book by clicking here.

Copyright 2004 CAB, Inc. All rights reserved. Republication or redistribution of CAB, Inc. content, including by framing or similar means, is expressly prohibited without the prior written consent of CAB, Inc. CAB, Inc. shall not be liable for any errors in the content, or for any actions taken in reliance thereon.