ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   VBA and Internet Explorer (https://www.excelbanter.com/excel-programming/433367-vba-internet-explorer.html)

Jamie

VBA and Internet Explorer
 
Hi guys

I have a simple bit of code which opens up Internet Explorer, navigates to a
web page, selects a value from a drop down menu (options are either "Yes" or
"No") and submits the form.

The code works fine if it is selecting "Yes" however if I change it to "No"
it dosn't work. Here is my code:

Sub photo_select()

strURL =
"http://corporate1.internal.standardlife.com/phoneline/Phnline.nsf/frmStaffUpdate"
Set objIE = CreateObject("InternetExplorer.Application")
objIE.Navigate strURL
objIE.Visible = False

While objIE.ReadyState < 4
Application.Wait Now + TimeValue("00:00:01")
Wend

objIE.Document.all("kwdshowphoto").Value = "Yes"

Call objIE.Document.Forms(0).Submit

objIE.Quit

End Sub

Here is part of the source code of the internal website, which relates to
the drop down:

<table border="0" width="100%" cellspacing="0" cellpadding="0"<a
width="100%" border="0" cellspacing="0" cellpadding="0"
<tr valign="top"<td class="sectionHead" width="350"<a width="1%"<img
width="359" height="1" src="/icons/ecblank.gif" border="0" alt=""<br
My location data / PhoneLine photo</td<td class="sectionHead" <a
width="100%"<img width="1" height="1" src="/icons/ecblank.gif" border="0"
alt=""<br
<div align="right"<a href="javascript:PhonelineHelp();" class="globalNav"
title="launch phoneline help"Help</a </div</td</tr

<tr valign="top"<td width="350"<a width="1%"<img width="359" height="1"
src="/icons/ecblank.gif" border="0" alt=""<br
</td<td <a width="100%"<img width="1" height="1" src="/icons/ecblank.gif"
border="0" alt=""<br
<br</td</tr

<tr valign="top"<td class="labelText" width="350"<a width="1%"<img
width="359" height="1" src="/icons/ecblank.gif" border="0" alt=""<br
Show my photo on Phoneline :</td<td class="dataText" <a width="100%"<img
width="1" height="1" src="/icons/ecblank.gif" border="0" alt=""<br
<font size="2"
<input name="%%Surrogate_kwdShowPhoto" type="hidden" value="1"
<select name="kwdShowPhoto"
<optionYes
<option selectedNo</select
</font </td</tr

<tr valign="top"<td width="1%"<img width="359" height="1"
src="/icons/ecblank.gif" border="0" alt=""<br
</td<td width="100%"<img width="1" height="1" src="/icons/ecblank.gif"
border="0" alt=""<br
<br</td</tr

Thanks in advance
Jamie

joel

VBA and Internet Explorer
 
Can you see on the webpage if No is getting enter in the form?

Why arre you using CALL. Does it work without call?

from
Call objIE.Document.Forms(0).Submit
to
objIE.Document.Forms(0).Submit


"Jamie" wrote:

Hi guys

I have a simple bit of code which opens up Internet Explorer, navigates to a
web page, selects a value from a drop down menu (options are either "Yes" or
"No") and submits the form.

The code works fine if it is selecting "Yes" however if I change it to "No"
it dosn't work. Here is my code:

Sub photo_select()

strURL =
"http://corporate1.internal.standardlife.com/phoneline/Phnline.nsf/frmStaffUpdate"
Set objIE = CreateObject("InternetExplorer.Application")
objIE.Navigate strURL
objIE.Visible = False

While objIE.ReadyState < 4
Application.Wait Now + TimeValue("00:00:01")
Wend

objIE.Document.all("kwdshowphoto").Value = "Yes"

Call objIE.Document.Forms(0).Submit

objIE.Quit

End Sub

Here is part of the source code of the internal website, which relates to
the drop down:

<table border="0" width="100%" cellspacing="0" cellpadding="0"<a
width="100%" border="0" cellspacing="0" cellpadding="0"
<tr valign="top"<td class="sectionHead" width="350"<a width="1%"<img
width="359" height="1" src="/icons/ecblank.gif" border="0" alt=""<br
My location data / PhoneLine photo</td<td class="sectionHead" <a
width="100%"<img width="1" height="1" src="/icons/ecblank.gif" border="0"
alt=""<br
<div align="right"<a href="javascript:PhonelineHelp();" class="globalNav"
title="launch phoneline help"Help</a </div</td</tr

<tr valign="top"<td width="350"<a width="1%"<img width="359" height="1"
src="/icons/ecblank.gif" border="0" alt=""<br
</td<td <a width="100%"<img width="1" height="1" src="/icons/ecblank.gif"
border="0" alt=""<br
<br</td</tr

<tr valign="top"<td class="labelText" width="350"<a width="1%"<img
width="359" height="1" src="/icons/ecblank.gif" border="0" alt=""<br
Show my photo on Phoneline :</td<td class="dataText" <a width="100%"<img
width="1" height="1" src="/icons/ecblank.gif" border="0" alt=""<br
<font size="2"
<input name="%%Surrogate_kwdShowPhoto" type="hidden" value="1"
<select name="kwdShowPhoto"
<optionYes
<option selectedNo</select
</font </td</tr

<tr valign="top"<td width="1%"<img width="359" height="1"
src="/icons/ecblank.gif" border="0" alt=""<br
</td<td width="100%"<img width="1" height="1" src="/icons/ecblank.gif"
border="0" alt=""<br
<br</td</tr

Thanks in advance
Jamie


Jamie

VBA and Internet Explorer
 
Hi Joel

I've changed the .visible to true so I can see it - and it dosn't change to
"No" therefore the problem is not with the submit statement, but the value
statement. I thought it was maybe because I had to use something like
..listindex rather than value?

Thanks for your time
Jamie

"Joel" wrote:

Can you see on the webpage if No is getting enter in the form?

Why arre you using CALL. Does it work without call?

from
Call objIE.Document.Forms(0).Submit
to
objIE.Document.Forms(0).Submit


"Jamie" wrote:

Hi guys

I have a simple bit of code which opens up Internet Explorer, navigates to a
web page, selects a value from a drop down menu (options are either "Yes" or
"No") and submits the form.

The code works fine if it is selecting "Yes" however if I change it to "No"
it dosn't work. Here is my code:

Sub photo_select()

strURL =
"http://corporate1.internal.standardlife.com/phoneline/Phnline.nsf/frmStaffUpdate"
Set objIE = CreateObject("InternetExplorer.Application")
objIE.Navigate strURL
objIE.Visible = False

While objIE.ReadyState < 4
Application.Wait Now + TimeValue("00:00:01")
Wend

objIE.Document.all("kwdshowphoto").Value = "Yes"

Call objIE.Document.Forms(0).Submit

objIE.Quit

End Sub

Here is part of the source code of the internal website, which relates to
the drop down:

<table border="0" width="100%" cellspacing="0" cellpadding="0"<a
width="100%" border="0" cellspacing="0" cellpadding="0"
<tr valign="top"<td class="sectionHead" width="350"<a width="1%"<img
width="359" height="1" src="/icons/ecblank.gif" border="0" alt=""<br
My location data / PhoneLine photo</td<td class="sectionHead" <a
width="100%"<img width="1" height="1" src="/icons/ecblank.gif" border="0"
alt=""<br
<div align="right"<a href="javascript:PhonelineHelp();" class="globalNav"
title="launch phoneline help"Help</a </div</td</tr

<tr valign="top"<td width="350"<a width="1%"<img width="359" height="1"
src="/icons/ecblank.gif" border="0" alt=""<br
</td<td <a width="100%"<img width="1" height="1" src="/icons/ecblank.gif"
border="0" alt=""<br
<br</td</tr

<tr valign="top"<td class="labelText" width="350"<a width="1%"<img
width="359" height="1" src="/icons/ecblank.gif" border="0" alt=""<br
Show my photo on Phoneline :</td<td class="dataText" <a width="100%"<img
width="1" height="1" src="/icons/ecblank.gif" border="0" alt=""<br
<font size="2"
<input name="%%Surrogate_kwdShowPhoto" type="hidden" value="1"
<select name="kwdShowPhoto"
<optionYes
<option selectedNo</select
</font </td</tr

<tr valign="top"<td width="1%"<img width="359" height="1"
src="/icons/ecblank.gif" border="0" alt=""<br
</td<td width="100%"<img width="1" height="1" src="/icons/ecblank.gif"
border="0" alt=""<br
<br</td</tr

Thanks in advance
Jamie


joel

VBA and Internet Explorer
 
I don't think you have the correct object selected. The form is just using
the default value. Another method is if the URL is different between Yes
and No then just go to the predefined URL.

"Jamie" wrote:

Hi Joel

I've changed the .visible to true so I can see it - and it dosn't change to
"No" therefore the problem is not with the submit statement, but the value
statement. I thought it was maybe because I had to use something like
.listindex rather than value?

Thanks for your time
Jamie

"Joel" wrote:

Can you see on the webpage if No is getting enter in the form?

Why arre you using CALL. Does it work without call?

from
Call objIE.Document.Forms(0).Submit
to
objIE.Document.Forms(0).Submit


"Jamie" wrote:

Hi guys

I have a simple bit of code which opens up Internet Explorer, navigates to a
web page, selects a value from a drop down menu (options are either "Yes" or
"No") and submits the form.

The code works fine if it is selecting "Yes" however if I change it to "No"
it dosn't work. Here is my code:

Sub photo_select()

strURL =
"http://corporate1.internal.standardlife.com/phoneline/Phnline.nsf/frmStaffUpdate"
Set objIE = CreateObject("InternetExplorer.Application")
objIE.Navigate strURL
objIE.Visible = False

While objIE.ReadyState < 4
Application.Wait Now + TimeValue("00:00:01")
Wend

objIE.Document.all("kwdshowphoto").Value = "Yes"

Call objIE.Document.Forms(0).Submit

objIE.Quit

End Sub

Here is part of the source code of the internal website, which relates to
the drop down:

<table border="0" width="100%" cellspacing="0" cellpadding="0"<a
width="100%" border="0" cellspacing="0" cellpadding="0"
<tr valign="top"<td class="sectionHead" width="350"<a width="1%"<img
width="359" height="1" src="/icons/ecblank.gif" border="0" alt=""<br
My location data / PhoneLine photo</td<td class="sectionHead" <a
width="100%"<img width="1" height="1" src="/icons/ecblank.gif" border="0"
alt=""<br
<div align="right"<a href="javascript:PhonelineHelp();" class="globalNav"
title="launch phoneline help"Help</a </div</td</tr

<tr valign="top"<td width="350"<a width="1%"<img width="359" height="1"
src="/icons/ecblank.gif" border="0" alt=""<br
</td<td <a width="100%"<img width="1" height="1" src="/icons/ecblank.gif"
border="0" alt=""<br
<br</td</tr

<tr valign="top"<td class="labelText" width="350"<a width="1%"<img
width="359" height="1" src="/icons/ecblank.gif" border="0" alt=""<br
Show my photo on Phoneline :</td<td class="dataText" <a width="100%"<img
width="1" height="1" src="/icons/ecblank.gif" border="0" alt=""<br
<font size="2"
<input name="%%Surrogate_kwdShowPhoto" type="hidden" value="1"
<select name="kwdShowPhoto"
<optionYes
<option selectedNo</select
</font </td</tr

<tr valign="top"<td width="1%"<img width="359" height="1"
src="/icons/ecblank.gif" border="0" alt=""<br
</td<td width="100%"<img width="1" height="1" src="/icons/ecblank.gif"
border="0" alt=""<br
<br</td</tr

Thanks in advance
Jamie


Jamie

VBA and Internet Explorer
 
Hi Joes

Thanks for the suggestion. I dont think the URL is different.
IS there a bit code I can run to get the names of all the objects on the page?

This is the code specific to the object:

Show my photo on Phoneline :</td<td class="dataText" <a width="100%"<img
width="1" height="1" src="/icons/ecblank.gif" border="0" alt=""<br
<font size="2"
<input name="%%Surrogate_kwdShowPhoto" type="hidden" value="1"
<select name="kwdShowPhoto"
<optionYes
<option selectedNo</select
</font </td</tr


Is it maybe %%Surrogate_kwdshowphoto?

Thanks
Jamie



"Joel" wrote:

I don't think you have the correct object selected. The form is just using
the default value. Another method is if the URL is different between Yes
and No then just go to the predefined URL.

"Jamie" wrote:

Hi Joel

I've changed the .visible to true so I can see it - and it dosn't change to
"No" therefore the problem is not with the submit statement, but the value
statement. I thought it was maybe because I had to use something like
.listindex rather than value?

Thanks for your time
Jamie

"Joel" wrote:

Can you see on the webpage if No is getting enter in the form?

Why arre you using CALL. Does it work without call?

from
Call objIE.Document.Forms(0).Submit
to
objIE.Document.Forms(0).Submit


"Jamie" wrote:

Hi guys

I have a simple bit of code which opens up Internet Explorer, navigates to a
web page, selects a value from a drop down menu (options are either "Yes" or
"No") and submits the form.

The code works fine if it is selecting "Yes" however if I change it to "No"
it dosn't work. Here is my code:

Sub photo_select()

strURL =
"http://corporate1.internal.standardlife.com/phoneline/Phnline.nsf/frmStaffUpdate"
Set objIE = CreateObject("InternetExplorer.Application")
objIE.Navigate strURL
objIE.Visible = False

While objIE.ReadyState < 4
Application.Wait Now + TimeValue("00:00:01")
Wend

objIE.Document.all("kwdshowphoto").Value = "Yes"

Call objIE.Document.Forms(0).Submit

objIE.Quit

End Sub

Here is part of the source code of the internal website, which relates to
the drop down:

<table border="0" width="100%" cellspacing="0" cellpadding="0"<a
width="100%" border="0" cellspacing="0" cellpadding="0"
<tr valign="top"<td class="sectionHead" width="350"<a width="1%"<img
width="359" height="1" src="/icons/ecblank.gif" border="0" alt=""<br
My location data / PhoneLine photo</td<td class="sectionHead" <a
width="100%"<img width="1" height="1" src="/icons/ecblank.gif" border="0"
alt=""<br
<div align="right"<a href="javascript:PhonelineHelp();" class="globalNav"
title="launch phoneline help"Help</a </div</td</tr

<tr valign="top"<td width="350"<a width="1%"<img width="359" height="1"
src="/icons/ecblank.gif" border="0" alt=""<br
</td<td <a width="100%"<img width="1" height="1" src="/icons/ecblank.gif"
border="0" alt=""<br
<br</td</tr

<tr valign="top"<td class="labelText" width="350"<a width="1%"<img
width="359" height="1" src="/icons/ecblank.gif" border="0" alt=""<br
Show my photo on Phoneline :</td<td class="dataText" <a width="100%"<img
width="1" height="1" src="/icons/ecblank.gif" border="0" alt=""<br
<font size="2"
<input name="%%Surrogate_kwdShowPhoto" type="hidden" value="1"
<select name="kwdShowPhoto"
<optionYes
<option selectedNo</select
</font </td</tr

<tr valign="top"<td width="1%"<img width="359" height="1"
src="/icons/ecblank.gif" border="0" alt=""<br
</td<td width="100%"<img width="1" height="1" src="/icons/ecblank.gif"
border="0" alt=""<br
<br</td</tr

Thanks in advance
Jamie


joel

VBA and Internet Explorer
 
Does the box show the ouble quotes around YES ? If you manually go to the
page and select No does it work? I thinking that Yes may be 1 and No may be
0.

Jamie

VBA and Internet Explorer
 
Hi mate

No the box dosn't show the quotes. If I click No it does work. I did try 0
and 1 but no luck.
I did get a workaround by doing objIE.document.all("kwdshowphoto").focus
then sendkeys "N"
but its still annoying :-(

Thanks for your time, appreciated

"Joel" wrote:

Does the box show the ouble quotes around YES ? If you manually go to the
page and select No does it work? I thinking that Yes may be 1 and No may be
0.

"Jamie" wrote:

Hi Joel

On further inspection, it is the correct object - debugging the code I can
see thatwhen I run the line which sets the value to "No" the dropdown box
goes blank - then when its submitted, it reverts to the default "Yes" as you
suggested.

Any ideas why it dos't like the "No"? Maybe because of the "hidden=1" part
in the source?

Thanks

"Jamie" wrote:

Hi Joes

Thanks for the suggestion. I dont think the URL is different.
IS there a bit code I can run to get the names of all the objects on the page?

This is the code specific to the object:

Show my photo on Phoneline :</td<td class="dataText" <a width="100%"<img
width="1" height="1" src="/icons/ecblank.gif" border="0" alt=""<br
<font size="2"
<input name="%%Surrogate_kwdShowPhoto" type="hidden" value="1"
<select name="kwdShowPhoto"
<optionYes
<option selectedNo</select
</font </td</tr

Is it maybe %%Surrogate_kwdshowphoto?

Thanks
Jamie



"Joel" wrote:

I don't think you have the correct object selected. The form is just using
the default value. Another method is if the URL is different between Yes
and No then just go to the predefined URL.

"Jamie" wrote:

Hi Joel

I've changed the .visible to true so I can see it - and it dosn't change to
"No" therefore the problem is not with the submit statement, but the value
statement. I thought it was maybe because I had to use something like
.listindex rather than value?

Thanks for your time
Jamie

"Joel" wrote:

Can you see on the webpage if No is getting enter in the form?

Why arre you using CALL. Does it work without call?

from
Call objIE.Document.Forms(0).Submit
to
objIE.Document.Forms(0).Submit


"Jamie" wrote:

Hi guys

I have a simple bit of code which opens up Internet Explorer, navigates to a
web page, selects a value from a drop down menu (options are either "Yes" or
"No") and submits the form.

The code works fine if it is selecting "Yes" however if I change it to "No"
it dosn't work. Here is my code:

Sub photo_select()

strURL =
"http://corporate1.internal.standardlife.com/phoneline/Phnline.nsf/frmStaffUpdate"
Set objIE = CreateObject("InternetExplorer.Application")
objIE.Navigate strURL
objIE.Visible = False

While objIE.ReadyState < 4
Application.Wait Now + TimeValue("00:00:01")
Wend

objIE.Document.all("kwdshowphoto").Value = "Yes"

Call objIE.Document.Forms(0).Submit

objIE.Quit

End Sub

Here is part of the source code of the internal website, which relates to
the drop down:

<table border="0" width="100%" cellspacing="0" cellpadding="0"<a
width="100%" border="0" cellspacing="0" cellpadding="0"
<tr valign="top"<td class="sectionHead" width="350"<a width="1%"<img
width="359" height="1" src="/icons/ecblank.gif" border="0" alt=""<br
My location data / PhoneLine photo</td<td class="sectionHead" <a
width="100%"<img width="1" height="1" src="/icons/ecblank.gif" border="0"
alt=""<br
<div align="right"<a href="javascript:PhonelineHelp();" class="globalNav"
title="launch phoneline help"Help</a </div</td</tr

<tr valign="top"<td width="350"<a width="1%"<img width="359" height="1"
src="/icons/ecblank.gif" border="0" alt=""<br
</td<td <a width="100%"<img width="1" height="1" src="/icons/ecblank.gif"
border="0" alt=""<br
<br</td</tr

<tr valign="top"<td class="labelText" width="350"<a width="1%"<img
width="359" height="1" src="/icons/ecblank.gif" border="0" alt=""<br
Show my photo on Phoneline :</td<td class="dataText" <a width="100%"<img
width="1" height="1" src="/icons/ecblank.gif" border="0" alt=""<br
<font size="2"
<input name="%%Surrogate_kwdShowPhoto" type="hidden" value="1"
<select name="kwdShowPhoto"
<optionYes
<option selectedNo</select
</font </td</tr

<tr valign="top"<td width="1%"<img width="359" height="1"
src="/icons/ecblank.gif" border="0" alt=""<br
</td<td width="100%"<img width="1" height="1" src="/icons/ecblank.gif"
border="0" alt=""<br
<br</td</tr

Thanks in advance
Jamie



All times are GMT +1. The time now is 01:30 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com