Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Access popup window from IE object.

I'm trying to get a reference to the InternetExplorer object that pops up
when I use VBA to fill out a form and click a link. I found the "NewWindow2"
event, but it doesn't seem to be doing what I want.

The NewWindow2 event fires when it should, but the "ppDisp" variable is set
to Nothing when I get into the function.

Any ideas what's going wrong?

Thanks,
Mayhew

Here's the code:
======================
Class Module IEClass:
======================
' class module "ieclass"
Public WithEvents x As InternetExplorer
Public y As InternetExplorer

Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal
lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function PostMessage Lib "user32" Alias "PostMessageA"
(ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam
As Long) As Long

Private Sub x_NewWindow2(ppDisp As Object, Cancel As Boolean)
Set y = ppDisp
End Sub

Public Sub SetVisible(visible As Boolean)
x.visible = visible
End Sub


Public Sub Navigate(destURL)
x.Navigate2 destURL
LoadPage
End Sub

Public Sub LoadPage()
' Pauses execution until the browser window has finished loading
Do While x.Busy Or x.ReadyState < READYSTATE_COMPLETE
PostMessage FindWindow("#32770", "Microsoft Internet Explorer"),
&H10, 0&, 0&
DoEvents
Loop
End Sub


Public Function Button_name(tagType, Caption As String) As Boolean
' Clicks the element of type tagType containing Caption or returns false if
element cannot be found
Dim Element

Button = True

Dim AllElements
Set AllElements = x.Document.getElementsByTagName(tagType)

For Each Element In AllElements
tempAlt = Element.Name
If InStr(Element.Name, Caption) 0 Then
Call Element.Click
Call LoadPage
Exit Function
End If
Next Element
Button = False
End Function

==================
Module 'Module1'
==================
Sub URL_Test2()
Dim ie1 As New IEClass
Set ie1.x = New InternetExplorer
ie1.SetVisible True

Dim varURL As String
varURL = "http://www.weather.gov/climate/index.php?wfo=box"
ie1.Navigate varURL

With ie1.x.Document.forms(2)
.Product(1).Click
.station.Options(2).Selected = True
.recent(1).Click
.Date.Options(0).Selected = True
End With
successful = ie1.Button_name("img", "goMain")
breakPointHere = True 'for breakpoint.

End Sub
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Popup window on open kraway Excel Discussion (Misc queries) 1 January 12th 07 03:19 PM
Popup window (plz replay) Tom Ogilvy Excel Programming 0 August 28th 03 04:45 AM
Popup window (plz replay) sd Excel Programming 2 August 28th 03 04:45 AM
Popup window (plz replay) Tom Ogilvy Excel Programming 0 August 27th 03 02:51 PM
Popup message window with name shah[_2_] Excel Programming 2 August 26th 03 02:40 AM


All times are GMT +1. The time now is 11:23 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"