ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   make selection in listbox html with vba (https://www.excelbanter.com/excel-programming/392644-make-selection-listbox-html-vba.html)

Dieru

make selection in listbox html with vba
 
Here is my first post

I have to make a selection in a listbox which is on a web page with
VBA. I have the beginning of the code :
Sub detecte()
lien = "my web adress"
Set IE = CreateObject("InternetExplorer.Application")
IE.Navigate lien
Do Until IE.ReadyState = 4
DoEvents
Loop 'attend la fin du chargement
IE.Visible = True
IE.Document.all("ucTitreRendu_DdSelDate").Value = "-1"

End Sub

the problem is with that code
"IE.Document.all("ucTitreRendu_DdSelDate").Val ue = "-1"", I only
select the first link but it does nothing. It should select the first
link and load the corresponding page.

for ex :
the selected link is march with the informations corresponding to
march.
if I select April from VBA I'd like to have the information
correponding to April.

Thanks for your help it's very important.


Dieru

make selection in listbox html with vba
 
Hellooo

Is anybody have a solution? May be it is too hard and I will not have
an answer or the subject does not interest you.


Tim Williams

make selection in listbox html with vba
 

This does not select anything:
IE.Document.all("ucTitreRendu_DdSelDate").Value = "-1"


Maybe you meant something like
IE.Document.all("ucTitreRendu_DdSelDate").selected Index = 0

This will select the first item in the list.
It's not clear how this loads the month's information: maybe via an
"onchange" event handler on the select ?

Tim


"Dieru" wrote in message
oups.com...
Hellooo

Is anybody have a solution? May be it is too hard and I will not have
an answer or the subject does not interest you.




Dieru

make selection in listbox html with vba
 
On 10 juil, 08:12, "Tim Williams" <timjwilliams at gmail dot com
wrote:
This does not select anything:

IE.Document.all("ucTitreRendu_DdSelDate").Value = "-1"


Maybe you meant something like
IE.Document.all("ucTitreRendu_DdSelDate").selected Index = 0

This will select the first item in the list.
It's not clear how this loads the month's information: maybe via an
"onchange" event handler on the select ?

Tim

Thanks Tim but with your code I have the same result. The page does
not update.
There is an onchange : "onchange="__doPostBack('ucTitreRendu
$DdSelDate','')"" but i don't know how to call this function from
Excel .



Tim

make selection in listbox html with vba
 
It would help if you could show the complete code you're using, as well as
the relevant source from the web page.

Tim


"Dieru" wrote in message
ups.com...
On 10 juil, 08:12, "Tim Williams" <timjwilliams at gmail dot com
wrote:
This does not select anything:

IE.Document.all("ucTitreRendu_DdSelDate").Value = "-1"


Maybe you meant something like
IE.Document.all("ucTitreRendu_DdSelDate").selected Index = 0

This will select the first item in the list.
It's not clear how this loads the month's information: maybe via an
"onchange" event handler on the select ?

Tim

Thanks Tim but with your code I have the same result. The page does
not update.
There is an onchange : "onchange="__doPostBack('ucTitreRendu
$DdSelDate','')"" but i don't know how to call this function from
Excel .





Dieru

make selection in listbox html with vba
 
On 10 juil, 18:10, "Tim" <tim j williams at gmail dot com wrote:
It would help if you could show the complete code you're using, as well as
the relevant source from the web page.

Tim

"Dieru" wrote in message

ups.com...



On 10 juil, 08:12, "Tim Williams" <timjwilliams at gmail dot com
wrote:
This does not select anything:


IE.Document.all("ucTitreRendu_DdSelDate").Value = "-1"


Maybe you meant something like
IE.Document.all("ucTitreRendu_DdSelDate").selected Index = 0


This will select the first item in the list.
It's not clear how this loads the month's information: maybe via an
"onchange" event handler on the select ?


Tim


Thanks Tim but with your code I have the same result. The page does
not update.
There is an onchange : "onchange="__doPostBack('ucTitreRendu
$DdSelDate','')"" but i don't know how to call this function from
Excel .- Masquer le texte des messages précédents -


- Afficher le texte des messages précédents -


Here is the code for the listbox :
<select language="javascript"
class="texteSmall" id="ucTitreRendu_DdSelDate"
style="border-style: none; width: 95%;"
onchange="__doPostBack('ucTitreRendu$DdSelDate','' )" ]=""
name="ucTitreRendu:DdSelDate"
<option value="-1"JUIN 2007 [en cours]</option
<option value="107" selected="selected"AVRIL
2007</option
</select
</td
</tr
</tbody
</table

And you already have the VBA code I am using.


Tim Williams

make selection in listbox html with vba
 
That HTML looks odd. There is no "language" attribute for select elements.

This should do it though:

With IE.Document.all("ucTitreRendu_DdSelDate")
.selectedIndex = 0
.onchange
End With

Tim



"Dieru" wrote in message
oups.com...
On 10 juil, 18:10, "Tim" <tim j williams at gmail dot com wrote:
It would help if you could show the complete code you're using, as well as
the relevant source from the web page.

Tim

"Dieru" wrote in message

ups.com...


- Afficher le texte des messages précédents -


Here is the code for the listbox :
<select language="javascript"
class="texteSmall" id="ucTitreRendu_DdSelDate"
style="border-style: none; width: 95%;"
onchange="__doPostBack('ucTitreRendu$DdSelDate','' )" ]=""
name="ucTitreRendu:DdSelDate"
<option value="-1"JUIN 2007 [en cours]</option
<option value="107" selected="selected"AVRIL
2007</option
</select
</td
</tr
</tbody
</table

And you already have the VBA code I am using.



Dieru

make selection in listbox html with vba
 
On 11 juil, 08:32, "Tim Williams" <timjwilliams at gmail dot com
wrote:
That HTML looks odd. There is no "language" attribute for select elements.

This should do it though:

With IE.Document.all("ucTitreRendu_DdSelDate")
.selectedIndex = 0
.onchange
End With

Tim

"Dieru" wrote in message

oups.com...
On 10 juil, 18:10, "Tim" <tim j williams at gmail dot com wrote:

It would help if you could show the complete code you're using, as well as
the relevant source from the web page.


Tim


"Dieru" wrote in message


oups.com...


- Afficher le texte des messages précédents -


Here is the code for the listbox :
<select language="javascript"
class="texteSmall" id="ucTitreRendu_DdSelDate"
style="border-style: none; width: 95%;"
onchange="__doPostBack('ucTitreRendu$DdSelDate','' )" ]=""
name="ucTitreRendu:DdSelDate"
<option value="-1"JUIN 2007 [en cours]</option
<option value="107" selected="selected"AVRIL
2007</option
</select
</td
</tr
</tbody
</table

And you already have the VBA code I am using.


Perfect Tim, thanks a lot.



All times are GMT +1. The time now is 05:14 PM.

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