Consulting

Results 1 to 6 of 6

Thread: Code in IE's Close event

  1. #1
    VBAX Regular
    Joined
    Feb 2007
    Posts
    68
    Location

    Question Code in IE's Close event

    Hi everyone,
    I use this code to load a new web-browser:
    [vba] Set ie = CreateObject("InternetExplorer.Application")
    ie.Visible = true [/vba]

    Now I want to show a message when it closes. Like some code in on_Exit event we apply in a web-browser event which is on a userform but this is not on a form but it is dynamically created . So any ideas?

    Thanks,
    Dan

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Can you monitor it continually?

    [vba]

    Set ie = CreateObject("InternetExplorer.Application")
    ie.Visible = True
    Do
    ieName = ""
    On Error Resume Next
    ieName = ie.Name
    On Error GoTo 0
    Loop Until ieName = ""
    [/vba]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    VBAX Regular
    Joined
    Feb 2007
    Posts
    68
    Location
    Hi xld,
    What will that code do ? For example if I nevigate the browser to yahoo.com then I click on close button & then what ?

    Thanks,
    Dan

  4. #4
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    That code will loop aroiund until IE is closed. It then cariies on.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  5. #5
    VBAX Contributor Ivan F Moala's Avatar
    Joined
    May 2004
    Location
    Auckland New Zealand
    Posts
    185
    Location
    you will need to create a Class module and instatiate the ie control, then use the controls event

    eg

    Set Refrence to [Microsoft internet controls] = shdocvw.dll

    create Class module named clsIE

    Option Explicit
    '// Class Name clsIE
    
    Public WithEvents IE As InternetExplorer
    
    Private Sub Class_Initialize()
        Set IE = New InternetExplorer
    End Sub
    
    Private Sub Class_Terminate()
        Set IE = Nothing
    End Sub
    
    Private Sub Ie_OnQuit()
        MsgBox "Closed now"
    End Sub

    Then STD Module

    Option Explicit
    
    Dim objApp As clsIE
    
    Sub Tester()
    '// Ivan F Moala
        Set objApp = New clsIE
         
        With objApp
            .IE.Visible = True
            .IE.Navigate ("http://vbaexpress.com/forum/showthread.php?t=15381")
        End With
    
    End Sub
    Kind Regards,
    Ivan F Moala From the City of Sails

  6. #6
    VBAX Regular
    Joined
    Feb 2007
    Posts
    68
    Location
    Hi Ivan,
    Your code worked fine. Thanks for quick help.

    Dan

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •