Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default navigating to an unnamed spawned window ?

I have the following VBA code to launch an IE application, navigate to a URL,
and submit a form.
The page which pops-up does not have a directly addressable URL, but is
generated
and directly filled-in by java when the form is submitted. What is the VBA
statement needed in the
following code to get a handle to the unnamed spawned page so that objects on
the page can be
referenced ?

Sub Clt_Data_Fetch()
Dim ie As Object

' launch IE and navigate to URL
Set ie = CreateObject("InternetExplorer.Application")
ie.Visible = True
ie.navigate "http://thisistheURL/index.html"

' wait for login page to come up
Do While ie.Busy: DoEvents: Loop
Do Until ie.ReadyState < 1: Loop

' fill in login form and submit
ie.document.all.Item("name").Value = "loginstring"
ie.document.all.Item("passwd").Value = "passwordstring"
ie.document.all.Item("submit").Click

' wait for spawned page to come up
Do While ie.Busy: DoEvents: Loop
Do Until ie.ReadyState < 1: Loop
Application.Wait (Now() + TimeValue("0:00:07"))

' close login page, leaving spawned page visible
ie.Quit

' *********** what is statement needed here to make reference to a 'table'
object with
' ID = "abcTab" in the unnamed spawned page ******************

endSub

--
tmp2100

Message posted via http://www.officekb.com
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,588
Default navigating to an unnamed spawned window ?

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



"tmp2100" <u21084@uwe wrote in message news:5f51884e56fca@uwe...
I have the following VBA code to launch an IE application, navigate to a URL,
and submit a form.
The page which pops-up does not have a directly addressable URL, but is
generated
and directly filled-in by java when the form is submitted. What is the VBA
statement needed in the
following code to get a handle to the unnamed spawned page so that objects on
the page can be
referenced ?

Sub Clt_Data_Fetch()
Dim ie As Object

' launch IE and navigate to URL
Set ie = CreateObject("InternetExplorer.Application")
ie.Visible = True
ie.navigate "http://thisistheURL/index.html"

' wait for login page to come up
Do While ie.Busy: DoEvents: Loop
Do Until ie.ReadyState < 1: Loop

' fill in login form and submit
ie.document.all.Item("name").Value = "loginstring"
ie.document.all.Item("passwd").Value = "passwordstring"
ie.document.all.Item("submit").Click

' wait for spawned page to come up
Do While ie.Busy: DoEvents: Loop
Do Until ie.ReadyState < 1: Loop
Application.Wait (Now() + TimeValue("0:00:07"))

' close login page, leaving spawned page visible
ie.Quit

' *********** what is statement needed here to make reference to a 'table'
object with
' ID = "abcTab" in the unnamed spawned page ******************

endSub

--
tmp2100

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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default navigating to an unnamed spawned window ?

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
  #4   Report Post  
Posted to microsoft.public.excel.programming
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



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default navigating to an unnamed spawned window ?

Tim:
I also found that changing the statement:
set oTable=oDoc.getElementById("abcTab")
to:
set oTable=oDoc.document.getElementById("abcTab")
also works as an alternative to your fix.

Now that oTable is set to the correct element, what statement(s) are needed
to cause the contents of oTable to be pasted back to the Excel spreadsheet
from which this macro is being run ?



================================================== ================
Tim Williams wrote:
Sorry, my mistake in the function.

Set retVal = o

should be:

Set retVal = o.document

Tim

Tim:
This appears to work. If I monitor the value of oDoc, the

[quoted text clipped - 55 lines]

endSub


--
tmp2100

Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200604/1


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,588
Default navigating to an unnamed spawned window ?

The document object model doesn't psermit a copy/paste operation, but you can access the individual rows/cells and get the content
from selected ones...

Eg:

Msgbox oTable.rows(2).cells(2).innerHTML

Tim

--
Tim Williams
Palo Alto, CA


"tmp2100 via OfficeKB.com" <u21084@uwe wrote in message news:5f696cb675e15@uwe...
Tim:
I also found that changing the statement:
set oTable=oDoc.getElementById("abcTab")
to:
set oTable=oDoc.document.getElementById("abcTab")
also works as an alternative to your fix.

Now that oTable is set to the correct element, what statement(s) are needed
to cause the contents of oTable to be pasted back to the Excel spreadsheet
from which this macro is being run ?



================================================== ================
Tim Williams wrote:
Sorry, my mistake in the function.

Set retVal = o

should be:

Set retVal = o.document

Tim

Tim:
This appears to work. If I monitor the value of oDoc, the

[quoted text clipped - 55 lines]

endSub


--
tmp2100

Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200604/1



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default navigating to an unnamed spawned window ?

Tim:
I presume that to pull in a big table, all I need is to do is, for example,
size the rows and cells counts large enough to match or exceed the size
of the target table ? for example,
Msgbox oTable.rows(10000).cells(100000).innerHTML

In your example, what is the subsequent statement needed to pull the complete
Msgbox
content into the spreadsheet from which the macro is being run ?

================================================== =============================
Tim Williams wrote:
The document object model doesn't psermit a copy/paste operation, but you can access the individual rows/cells and get the content
from selected ones...

Eg:

Msgbox oTable.rows(2).cells(2).innerHTML

Tim

Tim:
I also found that changing the statement:

[quoted text clipped - 23 lines]

endSub


--
tmp2100

Message posted via http://www.officekb.com
  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,588
Default navigating to an unnamed spawned window ?

rows(x) and cells(y) are indexes, not counts.

Rows have cells, so your example only pulls the content from the 100000th cell on the 10000th row.

Is your table really this large ?

You could try reading in the entire table using oTable.innerText and see what you get. Otherwise iterate through all the cells
copying each value in turn.

--
Tim Williams
Palo Alto, CA


"tmp2100 via OfficeKB.com" <u21084@uwe wrote in message news:5f6d118e84103@uwe...
Tim:
I presume that to pull in a big table, all I need is to do is, for example,
size the rows and cells counts large enough to match or exceed the size
of the target table ? for example,
Msgbox oTable.rows(10000).cells(100000).innerHTML

In your example, what is the subsequent statement needed to pull the complete
Msgbox
content into the spreadsheet from which the macro is being run ?

================================================== =============================
Tim Williams wrote:
The document object model doesn't psermit a copy/paste operation, but you can access the individual rows/cells and get the

content
from selected ones...

Eg:

Msgbox oTable.rows(2).cells(2).innerHTML

Tim

Tim:
I also found that changing the statement:

[quoted text clipped - 23 lines]

endSub


--
tmp2100

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



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
Unnamed Macro Error Andy Excel Worksheet Functions 2 August 24th 09 01:19 PM
Removing unnamed Legend lines from an Excel template rdemyan Charts and Charting in Excel 6 January 23rd 07 01:56 PM
The window opens in a smaller window not full sized window. Rachael Excel Discussion (Misc queries) 0 November 7th 06 09:04 PM
Two Excel sessions spawned at startup r0dsc0tt Excel Discussion (Misc queries) 1 September 17th 06 05:22 PM
Finding unnamed cells in a range 70Bob Excel Discussion (Misc queries) 3 June 21st 05 01:50 PM


All times are GMT +1. The time now is 04:28 AM.

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"