2

I used to close pop-up windows in VBA using the following code:

    Dim k As New shdocvw.ShellWindows   ' close menu window
    Dim c As WebBrowser
    For Each c In k
    If c.LocationURL = "http://specificsite.com/x.html" Then c.Quit()
    Next

You can see I have to check if the pop-up was opened and then close it.

I've migrated to VB.NET e2010 and it doesn't work.

I've found how to handle events and use the NewWindow to cancel the opening of the pop-up.

Unfortunately by cancelling instead of closing after it was opened, it causes a script error by JavaScript on the main page.

How can this be solved?

p.campbell
  • 98,673
  • 67
  • 256
  • 322
Paulo Bueno
  • 2,499
  • 6
  • 42
  • 68

1 Answers1

1

I was working on similar kind of project that i used shdocvw you can find it here

You could also find this one helpful this is using c# but you can convert it into VB Click Here

Nivid Dholakia
  • 5,272
  • 4
  • 30
  • 55
  • Both seems to use NewWindow event wich as i said, should not be used since the 'main' page fires an jscript based upon the pop-up window giving a error message, Wich i can't make silent since IE is IE. – Paulo Bueno Jan 17 '12 at 21:46