View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Tim Williams Tim Williams is offline
external usenet poster
 
Posts: 1,588
Default navigating to an unnamed spawned window ?

Sorry, my mistake in the function.

Set retVal = o

should be:

Set retVal = o.document

Tim

--
Tim Williams
Palo Alto, CA


"tmp2100 via OfficeKB.com" <u21084@uwe wrote in message news:5f5d79c69b1d1@uwe...
Tim:
This appears to work. If I monitor the value of oDoc, the
correct URL does show up. However, when the
set oTable=oDoc.getElementById("abcTab")
statement executes, a VB runtime error #438 occurs:
"object doesnt support this property or method"

Any suggestions on what's wrong?


Tim Williams wrote:
If you know the URL of the spawned window (look at the source for the form you're submitting)
then you can use the function below.
It will return the document object for the first window it finds with an address "like" the passed URL.
It a window is not found it will return nothing.

dim oDoc, oTable

set oDoc=GetHTMLDocument("htt p://thisistheURL/responsedir/")
if not oDoc is nothing then

set oTable=oDoc.getElementById("abcTab")

end if

Tim

'################################################ #
'Find an IE window with matching location and get the document from
' the loaded page. Assumes no frames.
Function GetHTMLDocument(sAddress As String) As Object

Dim objShell As Object, objShellWindows As Object, o As Object
Dim retVal As Object, sURL As String

Set retVal = Nothing
Set objShell = CreateObject("Shell.Application")
Set objShellWindows = objShell.Windows

'see if IE is already open
For Each o In objShellWindows
sURL = ""
On Error Resume Next
sURL = o.document.Location
On Error GoTo 0
If sURL < "" Then
If sURL Like sAddress & "*" Then
Set retVal = o
Exit For
End If
End If
Next o

Set GetHTMLDocument = retVal
End Function

I have the following VBA code to launch an IE application, navigate to a URL,
and submit a form.

[quoted text clipped - 36 lines]

endSub


--
tmp2100

Message posted via http://www.officekb.com