Ice223_3.zip
I have no idea and could not find any help on the internet. The event is firing but the argument, ppDisp, is pointing to nothing... Oh well, here is a good enough workaround that could be improved with a bit more work...
<table width="100%" border="1" bgcolor="White" style="filter
rogid:DXImageTransform.Microsoft.Gradient(endColorstr='#C0CFE2', startColorstr='#FFFFFF', gradientType='0');" ><td><font size="2" face=Courier New> <font color="#0000A0">Option</font> <font color="#0000A0">Explicit</font>
<font color="#008000">'set a reference to Microsoft Internet Controls or</font>
<font color="#008000">'Microsoft Browser Helpers</font>
<font color="#0000A0">Private</font> <font color="#0000A0">WithEvents</font> ie <font color="#0000A0">As</font> InternetExplorer
<font color="#0000A0">Private</font> iePopup <font color="#0000A0">As</font> InternetExplorer
<font color="#0000A0">Sub</font> Update()
<font color="#0000A0">Set</font> ie = <font color="#0000A0">New</font> InternetExplorer
<font color="#0000A0">With</font> ie
.Visible = True
.Navigate "http://www.dowjones.com/TheCompany/AboutDowJones.htm"
<font color="#0000A0">Do</font> <font color="#0000A0">Until</font> .ReadyState = 4: DoEvents: <font color="#0000A0">Loop</font>
<font color="#0000A0">Do</font> <font color="#0000A0">While</font> .Busy: DoEvents: <font color="#0000A0">Loop</font>
.Navigate "javascript
penWindow('/DJCom/Images/ContentImages/TheCompany/virtuouscircle.jpg',693,541)"
<font color="#0000A0">End</font> <font color="#0000A0">With</font>
<font color="#0000A0">If</font> iePopup <font color="#0000A0">Is</font> <font color="#0000A0">Nothing</font> <font color="#0000A0">Then</font>
<font color="#0000A0">Set</font> iePopup = GetInstance(TimeOutInSeconds:=5, _
URL:="11http://www.dowjones.com/DJCom/Images/ContentImages/TheCompany/virtuouscircle.jpg")
<font color="#0000A0">End</font> <font color="#0000A0">If</font>
<font color="#0000A0">If</font> <font color="#0000A0">Not</font> iePopup <font color="#0000A0">Is</font> <font color="#0000A0">Nothing</font> <font color="#0000A0">Then</font>
<font color="#008000"> 'work with your new window here</font>
MsgBox "hi"
<font color="#008000"> 'Would like code here to work with new window</font>
<font color="#0000A0">Else</font>
<font color="#008000"> 'failed to create or reference new window</font>
MsgBox "fail"
<font color="#0000A0">End</font> <font color="#0000A0">If</font>
<font color="#0000A0">End</font> <font color="#0000A0">Sub</font>
<font color="#0000A0">Private</font> <font color="#0000A0">Sub</font> ie_NewWindow2(ppDisp <font color="#0000A0">As</font> Object, Cancel <font color="#0000A0">As</font> Boolean)
<font color="#008000"> 'ppDisp will provide an object reference to the new instance</font>
<font color="#0000A0">Set</font> iePopup = ppDisp
<font color="#0000A0">End</font> <font color="#0000A0">Sub</font>
<font color="#0000A0">Private</font> <font color="#0000A0">Function</font> GetInstance(TimeOutInSeconds <font color="#0000A0">As</font> Double, <font color="#0000A0">Optional</font> URL <font color="#0000A0">As</font> String, _
<font color="#0000A0">Optional</font> LocationName <font color="#0000A0">As</font> String, <font color="#0000A0">Optional</font> WindowTitle <font color="#0000A0">As</font> String, _
<font color="#0000A0">Optional</font> Hwnd <font color="#0000A0">As</font> Long) <font color="#0000A0">As</font> InternetExplorer
<font color="#0000A0">On</font> <font color="#0000A0">Error</font> <font color="#0000A0">GoTo</font> Err_GetInstance
<font color="#0000A0">Dim</font> ShellWinList <font color="#0000A0">As</font> <font color="#0000A0">New</font> ShellWindows, o <font color="#0000A0">As</font> InternetExplorer
<font color="#0000A0">Dim</font> TimeOutTime <font color="#0000A0">As</font> <font color="#0000A0">Date</font>
TimeOutTime = DateAdd("s", TimeOutInSeconds, Now)
<font color="#0000A0">Do</font> <font color="#0000A0">Until</font> Now > TimeOutTime
<font color="#0000A0">For</font> <font color="#0000A0">Each</font> o <font color="#0000A0">In</font> ShellWinList
<font color="#0000A0">If</font> o.LocationURL = URL <font color="#0000A0">Then</font>
<font color="#0000A0">Set</font> GetInstance = o
<font color="#0000A0">Exit</font> <font color="#0000A0">Function</font>
<font color="#0000A0">End</font> <font color="#0000A0">If</font>
<font color="#0000A0">Next</font>
<font color="#0000A0">Loop</font>
<font color="#0000A0">Exit</font> <font color="#0000A0">Function</font>
Err_GetInstance:
<font color="#008000">'handle local errors</font>
<font color="#0000A0">End</font> <font color="#0000A0">Function</font>
</FONT></td></tr></table>
<button onclick='document.all("TomsCode2").value=document.all("TomsCode2").value.replace(/<br \/>\s\s/g,"");document.all("TomsCode2").value=document.all("TomsCode2").value.replace(/<br \/>/g,"");window.clipboardData.setData("Text",document.all("TomsCode2").value);'>Copy to Clipboard</BUTTON><textarea style="position:absolute;visibility:hidden" name="TomsCode2" wrap="virtual">
Option Explicit
'set a reference to Microsoft Internet Controls or
'Microsoft Browser Helpers
Private WithEvents ie As InternetExplorer
Private iePopup As InternetExplorer
Sub Update()
Set ie = New InternetExplorer
With ie
.Visible = True
.Navigate "http://www.dowjones.com/TheCompany/AboutDowJones.htm"
Do Until .ReadyState = 4: DoEvents: Loop
Do While .Busy: DoEvents: Loop
.Navigate "javascript
penWindow('/DJCom/Images/ContentImages/TheCompany/virtuouscircle.jpg',693,541)"
End With
If iePopup Is Nothing Then
Set iePopup = GetInstance(TimeOutInSeconds:=5, _
URL:="11http://www.dowjones.com/DJCom/Images/ContentImages/TheCompany/virtuouscircle.jpg")
End If
If Not iePopup Is Nothing Then
'work with your new window here
MsgBox "hi"
'Would like code here to work with new window
Else
'failed to create or reference new window
MsgBox "fail"
End If
End Sub
Private Sub ie_NewWindow2(ppDisp As Object, Cancel As Boolean)
'ppDisp will provide an object reference to the new instance
Set iePopup = ppDisp
End Sub
Private Function GetInstance(TimeOutInSeconds As Double, Optional URL As String, _
Optional LocationName As String, Optional WindowTitle As String, _
Optional Hwnd As Long) As InternetExplorer
On Error GoTo Err_GetInstance
Dim ShellWinList As New ShellWindows, o As InternetExplorer
Dim TimeOutTime As Date
TimeOutTime = DateAdd("s", TimeOutInSeconds, Now)
Do Until Now > TimeOutTime
For Each o In ShellWinList
If o.LocationURL = URL Then
Set GetInstance = o
Exit Function
End If
Next
Loop
Exit Function
Err_GetInstance:
'handle local errors
End Function
</textarea>
Ice223_3.zip