Trying to get info and control a "child" web page

B

Bruce

I am working on a project and have gotten to to a point where I need
assistance.

I have the following code:


Code:
Sub CommandButton1_Click() 'create a new window

Dim web As String
Dim AccountCol As Integer
Account_Col = 5
Switch_Col = 7
web = Sheets("sheet3").Range("B1").Value
DoBrowse1 web
End Sub


Sub DoBrowse1(url As String)
Dim TargetFrame As String
Set BTS = CreateObject("Internetexplorer.Application")
BTS.Visible = True
BTS.Navigate url
End Sub


Which opens up a page, this page I can programically navigate and open
another page
Code:
Private Sub CommandButton3_Click()
Dim i_CurRow As Integer


i_CurRow = ActiveCell.Row
'ActiveSheet.Cells(Row, col_ANONYMOUSCALL).Value = "YES"
T_Account = ActiveSheet.Cells(i_CurRow, Account_Col).Value
'T_Account = Sheets("Main").Cells(i_CurRow, Account_Col).Value
T_Switch = ActiveSheet.Cells(i_CurRow, Switch_Col).Value


If Not BTS Is Nothing Then
whatpage (BTS)
End If


If Not BTS.Visible = True Then
BTS.Visible = True
End If


With BTS.document.BTSQueryBean  'document name = "BTS" form name =
"BTSQueryBean"
.btsswitch.Value = Trim(T_Switch)
.ACCTNO.Value = Trim(T_Account)
.billingsys(1).Click
.submit '.Click
End With
' calls BTS Detail screen
'waiting (40)
WaitReady
waiting (2)
spage = BTS.document.DocumentElement.outerHTML
CMTSValue = BTS.document.BTSDetailBean.CMTS.Value
AcctValue = BTS.document.BTSDetailBean.ACCTNO.Value
End Sub


All is good to this point, now, my next button, goes to a child of the
above page, and here is where I lose control.... The child is NOT
using the handle of the parent (BTS) so, how can I get data to and
from it? And submit the apply or close buttons


Code:
Private Sub FeaturesLine1_Click()
With BTS.document.BTSDetailBean  'document name = "BTS" form name =
"BTSDetailBean"
.featid0.Click    'This launched the features screen, which I
cannot control!<<<<<<
End With


End Sub


This now opens a new windows, no scroll balls, or ie menus (modeless?)
screen, almost like a popup, that has data I need to retrieve and then
possibly change and finally hit the "APPLY and then the "CLOSE"
button.


the HTML for the child page is available, but here are some of the key
points:
Here is the calling button press:
<input type="button" value="FEATURES" class="button" id="featid0"
onClick="launchFeatures('0', 'RTPKCABTPS0', 'S8770350472355221-1',
'0', 'CTXG_INDIVIDUAL', 'CHANGE', 'null');">


Here is the code that actually launches the child
Code:
function launchFeatures(a, b, c, i, catg, act, racfpilot)
{
var m,u;
var tn =  document.BTSDetailBean.subservtn[i].value;
if ( tn == null || tn == "" )
{
alert ("Please enter subscriber telephone number")
return false;
}


u = "./feature.jsp?subidx=" + a + "&clli=" + b + "&subid=" + c +
"&subtn=" + tn + "&catg=" + catg + "&action=" + act +
"&racfpilotcode=" + racfpilot;
MM_openBrWindow(u,'locked','scrollbars=1,resizable=1');
return true;


}

The child page's form name is


<form name="BTSFeatureBean" method="POST" action="/bts/jsp/
btsfeat.do">


Any ideas how I could do this?
Thanks
 
T

Tim Williams

Here's a function which you can use to get a reference to an open IE window
with a URL matching some kind of pattern (or adjust to an exact match if
required).
You can use this to get a reference to the child window (once it has opened
and completed loading, so insert a wait of a few secs before trying).
To get the URL of the popup window, select it and press Ctrl+N: that will
open a "chromed" window with a visible URL. Or uncomment the Debug.Print
line to see the URL for all open windows.

'******************************
'Find an IE window with a matching (partial) URL
'Assumes no frames.
Function GetIE(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
'Debug.Print sURL
If sURL Like sAddress & "*" Then
Set retVal = o
Exit For
End If
End If
Next o

Set GetIE = retVal
End Function
'******************************

To use:

Dim ieNew as object, doc as object

Set ieNew = GetIE("http:\\server.com/partialURL/")

If Not ieNew is Nothing then
set doc = ieNew.document
'do stuff with root document object
Else
Msgbox "No new window found"
End If




Tim






Bruce said:
I am working on a project and have gotten to to a point where I need
assistance.

I have the following code:


Code:
Sub CommandButton1_Click() 'create a new window

Dim web As String
Dim AccountCol As Integer
Account_Col = 5
Switch_Col = 7
web = Sheets("sheet3").Range("B1").Value
DoBrowse1 web
End Sub


Sub DoBrowse1(url As String)
Dim TargetFrame As String
Set BTS = CreateObject("Internetexplorer.Application")
BTS.Visible = True
BTS.Navigate url
End Sub


Which opens up a page, this page I can programically navigate and open
another page
Code:
Private Sub CommandButton3_Click()
Dim i_CurRow As Integer


i_CurRow = ActiveCell.Row
'ActiveSheet.Cells(Row, col_ANONYMOUSCALL).Value = "YES"
T_Account = ActiveSheet.Cells(i_CurRow, Account_Col).Value
'T_Account = Sheets("Main").Cells(i_CurRow, Account_Col).Value
T_Switch = ActiveSheet.Cells(i_CurRow, Switch_Col).Value


If Not BTS Is Nothing Then
whatpage (BTS)
End If


If Not BTS.Visible = True Then
BTS.Visible = True
End If


With BTS.document.BTSQueryBean  'document name = "BTS" form name =
"BTSQueryBean"
.btsswitch.Value = Trim(T_Switch)
.ACCTNO.Value = Trim(T_Account)
.billingsys(1).Click
.submit '.Click
End With
' calls BTS Detail screen
'waiting (40)
WaitReady
waiting (2)
spage = BTS.document.DocumentElement.outerHTML
CMTSValue = BTS.document.BTSDetailBean.CMTS.Value
AcctValue = BTS.document.BTSDetailBean.ACCTNO.Value
End Sub


All is good to this point, now, my next button, goes to a child of the
above page, and here is where I lose control.... The child is NOT
using the handle of the parent (BTS) so, how can I get data to and
from it? And submit the apply or close buttons


Code:
Private Sub FeaturesLine1_Click()
With BTS.document.BTSDetailBean  'document name = "BTS" form name =
"BTSDetailBean"
.featid0.Click    'This launched the features screen, which I
cannot control!<<<<<<
End With


End Sub


This now opens a new windows, no scroll balls, or ie menus (modeless?)
screen, almost like a popup, that has data I need to retrieve and then
possibly change and finally hit the "APPLY and then the "CLOSE"
button.


the HTML for the child page is available, but here are some of the key
points:
Here is the calling button press:
<input type="button" value="FEATURES" class="button" id="featid0"
onClick="launchFeatures('0', 'RTPKCABTPS0', 'S8770350472355221-1',
'0', 'CTXG_INDIVIDUAL', 'CHANGE', 'null');">


Here is the code that actually launches the child
Code:
function launchFeatures(a, b, c, i, catg, act, racfpilot)
{
var m,u;
var tn =  document.BTSDetailBean.subservtn[i].value;
if ( tn == null || tn == "" )
{
alert ("Please enter subscriber telephone number")
return false;
}


u = "./feature.jsp?subidx=" + a + "&clli=" + b + "&subid=" + c +
"&subtn=" + tn + "&catg=" + catg + "&action=" + act +
"&racfpilotcode=" + racfpilot;
MM_openBrWindow(u,'locked','scrollbars=1,resizable=1');
return true;


}

The child page's form name is


<form name="BTSFeatureBean" method="POST" action="/bts/jsp/
btsfeat.do">


Any ideas how I could do this?
Thanks
 
B

Bruce

Thank you very much Tim! I will try this when I get into the office in the
AM


Thank you very much!
Bruce

Tim Williams said:
Here's a function which you can use to get a reference to an open IE
window with a URL matching some kind of pattern (or adjust to an exact
match if required).
You can use this to get a reference to the child window (once it has
opened and completed loading, so insert a wait of a few secs before
trying).
To get the URL of the popup window, select it and press Ctrl+N: that will
open a "chromed" window with a visible URL. Or uncomment the Debug.Print
line to see the URL for all open windows.

'******************************
'Find an IE window with a matching (partial) URL
'Assumes no frames.
Function GetIE(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
'Debug.Print sURL
If sURL Like sAddress & "*" Then
Set retVal = o
Exit For
End If
End If
Next o

Set GetIE = retVal
End Function
'******************************

To use:

Dim ieNew as object, doc as object

Set ieNew = GetIE("http:\\server.com/partialURL/")

If Not ieNew is Nothing then
set doc = ieNew.document
'do stuff with root document object
Else
Msgbox "No new window found"
End If




Tim






Bruce said:
I am working on a project and have gotten to to a point where I need
assistance.

I have the following code:


Code:
Sub CommandButton1_Click() 'create a new window

Dim web As String
Dim AccountCol As Integer
Account_Col = 5
Switch_Col = 7
web = Sheets("sheet3").Range("B1").Value
DoBrowse1 web
End Sub


Sub DoBrowse1(url As String)
Dim TargetFrame As String
Set BTS = CreateObject("Internetexplorer.Application")
BTS.Visible = True
BTS.Navigate url
End Sub


Which opens up a page, this page I can programically navigate and open
another page
Code:
Private Sub CommandButton3_Click()
Dim i_CurRow As Integer


i_CurRow = ActiveCell.Row
'ActiveSheet.Cells(Row, col_ANONYMOUSCALL).Value = "YES"
T_Account = ActiveSheet.Cells(i_CurRow, Account_Col).Value
'T_Account = Sheets("Main").Cells(i_CurRow, Account_Col).Value
T_Switch = ActiveSheet.Cells(i_CurRow, Switch_Col).Value


If Not BTS Is Nothing Then
whatpage (BTS)
End If


If Not BTS.Visible = True Then
BTS.Visible = True
End If


With BTS.document.BTSQueryBean  'document name = "BTS" form name =
"BTSQueryBean"
.btsswitch.Value = Trim(T_Switch)
.ACCTNO.Value = Trim(T_Account)
.billingsys(1).Click
.submit '.Click
End With
' calls BTS Detail screen
'waiting (40)
WaitReady
waiting (2)
spage = BTS.document.DocumentElement.outerHTML
CMTSValue = BTS.document.BTSDetailBean.CMTS.Value
AcctValue = BTS.document.BTSDetailBean.ACCTNO.Value
End Sub


All is good to this point, now, my next button, goes to a child of the
above page, and here is where I lose control.... The child is NOT
using the handle of the parent (BTS) so, how can I get data to and
from it? And submit the apply or close buttons


Code:
Private Sub FeaturesLine1_Click()
With BTS.document.BTSDetailBean  'document name = "BTS" form name =
"BTSDetailBean"
.featid0.Click    'This launched the features screen, which I
cannot control!<<<<<<
End With


End Sub


This now opens a new windows, no scroll balls, or ie menus (modeless?)
screen, almost like a popup, that has data I need to retrieve and then
possibly change and finally hit the "APPLY and then the "CLOSE"
button.


the HTML for the child page is available, but here are some of the key
points:
Here is the calling button press:
<input type="button" value="FEATURES" class="button" id="featid0"
onClick="launchFeatures('0', 'RTPKCABTPS0', 'S8770350472355221-1',
'0', 'CTXG_INDIVIDUAL', 'CHANGE', 'null');">


Here is the code that actually launches the child
Code:
function launchFeatures(a, b, c, i, catg, act, racfpilot)
{
var m,u;
var tn =  document.BTSDetailBean.subservtn[i].value;
if ( tn == null || tn == "" )
{
alert ("Please enter subscriber telephone number")
return false;
}


u = "./feature.jsp?subidx=" + a + "&clli=" + b + "&subid=" + c +
"&subtn=" + tn + "&catg=" + catg + "&action=" + act +
"&racfpilotcode=" + racfpilot;
MM_openBrWindow(u,'locked','scrollbars=1,resizable=1');
return true;


}

The child page's form name is


<form name="BTSFeatureBean" method="POST" action="/bts/jsp/
btsfeat.do">


Any ideas how I could do this?
Thanks
 
B

Bruce

Tim, I tried this with GOOGLE, and I keep getting a "Run-time error '438'
Object doesn't support this property or method"
Here is the code I am using

'To use:
Sub getgoogle()
Dim ieNew As Object, doc As Object

Set ieNew = GetIE("http://www.google.com/")

If Not ieNew Is Nothing Then
Set doc = ieNew.document

With doc
.Visible = 1 '<< Here is where I get the error. Is this the correct
syntax?
End With

'do stuff with root document object
MsgBox doc

Else
MsgBox "No new window found"
End If


End Sub


Thanks!
Bruce

Tim Williams said:
Here's a function which you can use to get a reference to an open IE
window with a URL matching some kind of pattern (or adjust to an exact
match if required).
You can use this to get a reference to the child window (once it has
opened and completed loading, so insert a wait of a few secs before
trying).
To get the URL of the popup window, select it and press Ctrl+N: that will
open a "chromed" window with a visible URL. Or uncomment the Debug.Print
line to see the URL for all open windows.

'******************************
'Find an IE window with a matching (partial) URL
'Assumes no frames.
Function GetIE(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
'Debug.Print sURL
If sURL Like sAddress & "*" Then
Set retVal = o
Exit For
End If
End If
Next o

Set GetIE = retVal
End Function
'******************************

To use:

Dim ieNew as object, doc as object

Set ieNew = GetIE("http:\\server.com/partialURL/")

If Not ieNew is Nothing then
set doc = ieNew.document
'do stuff with root document object
Else
Msgbox "No new window found"
End If




Tim






Bruce said:
I am working on a project and have gotten to to a point where I need
assistance.

I have the following code:


Code:
Sub CommandButton1_Click() 'create a new window

Dim web As String
Dim AccountCol As Integer
Account_Col = 5
Switch_Col = 7
web = Sheets("sheet3").Range("B1").Value
DoBrowse1 web
End Sub


Sub DoBrowse1(url As String)
Dim TargetFrame As String
Set BTS = CreateObject("Internetexplorer.Application")
BTS.Visible = True
BTS.Navigate url
End Sub


Which opens up a page, this page I can programically navigate and open
another page
Code:
Private Sub CommandButton3_Click()
Dim i_CurRow As Integer


i_CurRow = ActiveCell.Row
'ActiveSheet.Cells(Row, col_ANONYMOUSCALL).Value = "YES"
T_Account = ActiveSheet.Cells(i_CurRow, Account_Col).Value
'T_Account = Sheets("Main").Cells(i_CurRow, Account_Col).Value
T_Switch = ActiveSheet.Cells(i_CurRow, Switch_Col).Value


If Not BTS Is Nothing Then
whatpage (BTS)
End If


If Not BTS.Visible = True Then
BTS.Visible = True
End If


With BTS.document.BTSQueryBean  'document name = "BTS" form name =
"BTSQueryBean"
.btsswitch.Value = Trim(T_Switch)
.ACCTNO.Value = Trim(T_Account)
.billingsys(1).Click
.submit '.Click
End With
' calls BTS Detail screen
'waiting (40)
WaitReady
waiting (2)
spage = BTS.document.DocumentElement.outerHTML
CMTSValue = BTS.document.BTSDetailBean.CMTS.Value
AcctValue = BTS.document.BTSDetailBean.ACCTNO.Value
End Sub


All is good to this point, now, my next button, goes to a child of the
above page, and here is where I lose control.... The child is NOT
using the handle of the parent (BTS) so, how can I get data to and
from it? And submit the apply or close buttons


Code:
Private Sub FeaturesLine1_Click()
With BTS.document.BTSDetailBean  'document name = "BTS" form name =
"BTSDetailBean"
.featid0.Click    'This launched the features screen, which I
cannot control!<<<<<<
End With


End Sub


This now opens a new windows, no scroll balls, or ie menus (modeless?)
screen, almost like a popup, that has data I need to retrieve and then
possibly change and finally hit the "APPLY and then the "CLOSE"
button.


the HTML for the child page is available, but here are some of the key
points:
Here is the calling button press:
<input type="button" value="FEATURES" class="button" id="featid0"
onClick="launchFeatures('0', 'RTPKCABTPS0', 'S8770350472355221-1',
'0', 'CTXG_INDIVIDUAL', 'CHANGE', 'null');">


Here is the code that actually launches the child
Code:
function launchFeatures(a, b, c, i, catg, act, racfpilot)
{
var m,u;
var tn =  document.BTSDetailBean.subservtn[i].value;
if ( tn == null || tn == "" )
{
alert ("Please enter subscriber telephone number")
return false;
}


u = "./feature.jsp?subidx=" + a + "&clli=" + b + "&subid=" + c +
"&subtn=" + tn + "&catg=" + catg + "&action=" + act +
"&racfpilotcode=" + racfpilot;
MM_openBrWindow(u,'locked','scrollbars=1,resizable=1');
return true;


}

The child page's form name is


<form name="BTSFeatureBean" method="POST" action="/bts/jsp/
btsfeat.do">


Any ideas how I could do this?
Thanks
 
T

Tim Williams

The document object doesn't have a visible property - you would set that on
the IE window

ieNew.visible=true

but it should already be visible if it's a child window.

Tim


Bruce said:
Tim, I tried this with GOOGLE, and I keep getting a "Run-time error '438'
Object doesn't support this property or method"
Here is the code I am using

'To use:
Sub getgoogle()
Dim ieNew As Object, doc As Object

Set ieNew = GetIE("http://www.google.com/")

If Not ieNew Is Nothing Then
Set doc = ieNew.document

With doc
.Visible = 1 '<< Here is where I get the error. Is this the correct
syntax?
End With

'do stuff with root document object
MsgBox doc

Else
MsgBox "No new window found"
End If


End Sub


Thanks!
Bruce

Tim Williams said:
Here's a function which you can use to get a reference to an open IE
window with a URL matching some kind of pattern (or adjust to an exact
match if required).
You can use this to get a reference to the child window (once it has
opened and completed loading, so insert a wait of a few secs before
trying).
To get the URL of the popup window, select it and press Ctrl+N: that will
open a "chromed" window with a visible URL. Or uncomment the Debug.Print
line to see the URL for all open windows.

'******************************
'Find an IE window with a matching (partial) URL
'Assumes no frames.
Function GetIE(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
'Debug.Print sURL
If sURL Like sAddress & "*" Then
Set retVal = o
Exit For
End If
End If
Next o

Set GetIE = retVal
End Function
'******************************

To use:

Dim ieNew as object, doc as object

Set ieNew = GetIE("http:\\server.com/partialURL/")

If Not ieNew is Nothing then
set doc = ieNew.document
'do stuff with root document object
Else
Msgbox "No new window found"
End If




Tim






Bruce said:
I am working on a project and have gotten to to a point where I need
assistance.

I have the following code:


Code:
Sub CommandButton1_Click() 'create a new window

Dim web As String
Dim AccountCol As Integer
Account_Col = 5
Switch_Col = 7
web = Sheets("sheet3").Range("B1").Value
DoBrowse1 web
End Sub


Sub DoBrowse1(url As String)
Dim TargetFrame As String
Set BTS = CreateObject("Internetexplorer.Application")
BTS.Visible = True
BTS.Navigate url
End Sub


Which opens up a page, this page I can programically navigate and open
another page
Code:
Private Sub CommandButton3_Click()
Dim i_CurRow As Integer


i_CurRow = ActiveCell.Row
'ActiveSheet.Cells(Row, col_ANONYMOUSCALL).Value = "YES"
T_Account = ActiveSheet.Cells(i_CurRow, Account_Col).Value
'T_Account = Sheets("Main").Cells(i_CurRow, Account_Col).Value
T_Switch = ActiveSheet.Cells(i_CurRow, Switch_Col).Value


If Not BTS Is Nothing Then
whatpage (BTS)
End If


If Not BTS.Visible = True Then
BTS.Visible = True
End If


With BTS.document.BTSQueryBean  'document name = "BTS" form name =
"BTSQueryBean"
.btsswitch.Value = Trim(T_Switch)
.ACCTNO.Value = Trim(T_Account)
.billingsys(1).Click
.submit '.Click
End With
' calls BTS Detail screen
'waiting (40)
WaitReady
waiting (2)
spage = BTS.document.DocumentElement.outerHTML
CMTSValue = BTS.document.BTSDetailBean.CMTS.Value
AcctValue = BTS.document.BTSDetailBean.ACCTNO.Value
End Sub


All is good to this point, now, my next button, goes to a child of the
above page, and here is where I lose control.... The child is NOT
using the handle of the parent (BTS) so, how can I get data to and
from it? And submit the apply or close buttons


Code:
Private Sub FeaturesLine1_Click()
With BTS.document.BTSDetailBean  'document name = "BTS" form name =
"BTSDetailBean"
.featid0.Click    'This launched the features screen, which I
cannot control!<<<<<<
End With


End Sub


This now opens a new windows, no scroll balls, or ie menus (modeless?)
screen, almost like a popup, that has data I need to retrieve and then
possibly change and finally hit the "APPLY and then the "CLOSE"
button.


the HTML for the child page is available, but here are some of the key
points:
Here is the calling button press:
<input type="button" value="FEATURES" class="button" id="featid0"
onClick="launchFeatures('0', 'RTPKCABTPS0', 'S8770350472355221-1',
'0', 'CTXG_INDIVIDUAL', 'CHANGE', 'null');">


Here is the code that actually launches the child
Code:
function launchFeatures(a, b, c, i, catg, act, racfpilot)
{
var m,u;
var tn =  document.BTSDetailBean.subservtn[i].value;
if ( tn == null || tn == "" )
{
alert ("Please enter subscriber telephone number")
return false;
}


u = "./feature.jsp?subidx=" + a + "&clli=" + b + "&subid=" + c +
"&subtn=" + tn + "&catg=" + catg + "&action=" + act +
"&racfpilotcode=" + racfpilot;
MM_openBrWindow(u,'locked','scrollbars=1,resizable=1');
return true;


}

The child page's form name is


<form name="BTSFeatureBean" method="POST" action="/bts/jsp/
btsfeat.do">


Any ideas how I could do this?
Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top