Click here to Skip to main content
15,886,518 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I have one project created with VB 6.0. Below is the code.

Step to reproduced this issue,

1. Start Internet explorer and add the site "https://subscribe.qa.s.vonagenetworks.net/plans" to trusted site. now set protected mode check box to Off for the trusted site zone.

2. Open the Visual Basic 6.0 and created standard Exe project.

3. From Tools ->; references add "Microsoft Internet Controls".

4. Copy and Paste below code.

'General Declaration

Dim WithEvents ie As SHDocVw.InternetExplorer

Private Sub Form_Load()

Set ie = CreateObject("InternetExplorer.Application")
ie.Navigate2 "https://subscribe.qa.s.vonagenetworks.net/plans"
ie.Visible = True

End Sub


Private Sub ie_DocumentComplete(ByVal pDisp As Object, URL As Variant)

MsgBox "Document complete."

End Sub

Private Sub ie_OnQuit()

MsgBox "IE quit."

End Sub


Now the problem what I am facing is that when I ran this code It opens the IE and navigate to the given URL but suddenly it called the onQuit event though the IE is still open. If I set the Protected mode ON for the Trusted site zone it is working fine and IE_Document complete called perfectly.

I am using Windows 7 Professional and Internet Explorer 8.

May I know what is the issue? What should I do to make it run for both setting i.e. Protected Mode On or OFF.
Posted

1 solution

Why not adding a button?

I have been working with VB and
VB
Set ie = CreateObject("InternetExplorer.Application")

and I had never any problem that IE all of a sudden quits by itself.

A piece of my code I used in the past and I'm still using :

VB
'Create Internet Explorer Application, going on the internet!
Set ie = CreateObject("InternetExplorer.Application")

'Internet Explorer Visible
ie.Visible = True

'Internet Explorer Left & Top Position on the screen
ie.Left = 0
ie.Top = 0

'Internet Explorer Height & Width Settings
ie.Height = 1024
ie.Width = 1280

'Internet Explorer Navigate To Facebook
ie.Navigate2 "http://www.facebook.com"

To stop IE I use a command button with as code under the click event :

'Stop & Close Internet Explorer
ie.Stop
ie.Quit


-------
IE.onquit thus not advisable if you follow the MSDN Library http://msdn.microsoft.com/en-us/library/cc136549.aspx[^] if you use the WebBrowser Object http://msdn.microsoft.com/en-us/library/aa752085.aspx[^] offcourse.
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900