Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 108
Default Automanipulating IE drop-down list in VBA/Excel

I'm strictly a newbie in VB; I've been programming on the mainframe for
decades but am only recently come to VBA, VBScript etc, so if you notice that
I'm going about this all wrong, be sure and point me in a better direction.
I have a spreadsheet that contains data from the web, and I'd like to make it
smart enough to update itself when I tell it to. I've learned a little about
the "Document" object model, and have gotten to the point where I can browse
down through all the .Document.All items and figure out which ones I want VBA
to manipulate. I can even fill in the values of web pages' text boxes and
simulate a .Click on its buttons.

But now I want to make a selection from a drop-down box. Let's say it has a
list of states on it: I want my VBA program to pick out the correct state
and convince the web page that I've chosen it. I've found the Option items
that define the possible selections, and I see that if I find the correct one
and change its Selected property to True, it shows up on the page correctly
as though I selected it myself.

But what the page doesn't do is proceed from that point as though I had
clicked on the item - that is, it shows up in the drop-down selection box,
but I can't get it to go forward from there. I've tried .Clicking on
everything I can think of (might have missed one, though), but nothing seems
to work. What am I supposed to do to get to the next step.

If there's a FAQ on this, or another forum I should post to, just point me
in the right direction. And if there's an easier way than using the Document
object model - which wouldn't surprise me - feel free to point that out to
me, too. Thanks.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,588
Default Automanipulating IE drop-down list in VBA/Excel

Is this a drop-down which when changed should trigger some kind of action ?

Try selecting the option and then calling the "onchange" event handler:

Set t = IE.document.getElementById("slctColor")
t.selectedIndex = 2
t.onchange


Tim


"Bob Bridges" wrote in message
...
I'm strictly a newbie in VB; I've been programming on the mainframe for
decades but am only recently come to VBA, VBScript etc, so if you notice
that
I'm going about this all wrong, be sure and point me in a better
direction.
I have a spreadsheet that contains data from the web, and I'd like to make
it
smart enough to update itself when I tell it to. I've learned a little
about
the "Document" object model, and have gotten to the point where I can
browse
down through all the .Document.All items and figure out which ones I want
VBA
to manipulate. I can even fill in the values of web pages' text boxes and
simulate a .Click on its buttons.

But now I want to make a selection from a drop-down box. Let's say it has
a
list of states on it: I want my VBA program to pick out the correct state
and convince the web page that I've chosen it. I've found the Option
items
that define the possible selections, and I see that if I find the correct
one
and change its Selected property to True, it shows up on the page
correctly
as though I selected it myself.

But what the page doesn't do is proceed from that point as though I had
clicked on the item - that is, it shows up in the drop-down selection box,
but I can't get it to go forward from there. I've tried .Clicking on
everything I can think of (might have missed one, though), but nothing
seems
to work. What am I supposed to do to get to the next step.

If there's a FAQ on this, or another forum I should post to, just point me
in the right direction. And if there's an easier way than using the
Document
object model - which wouldn't surprise me - feel free to point that out to
me, too. Thanks.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 108
Default Automanipulating IE drop-down list in VBA/Excel

The object I'm working with appears to have the TypeName "HTMLSelectElement".
I don't see the OnChange method for the select object in the DOM
documentation.

But you got me started: There's something called fireEvent that I can use
to simulate the OnChange event by simply naming it:

t.fireEvent("OnChange")

I'll play with it after I've gotten some sleep. If I'm on the wrong track,
feel free to say so; I'm still discovering where all the documentation is
hiding. Thanks.

--- "Tim Williams" wrote:
Is this a drop-down which when changed should trigger some kind of action ?
Try selecting the option and then calling the "onchange" event handler:

Set t = IE.document.getElementById("slctColor")
t.selectedIndex = 2
t.onchange

--- "Bob Bridges" wrote in message
...
I'm strictly a newbie in VB; I've been programming on the mainframe for
decades but am only recently come to VBA, VBScript etc, so if you notice
that I'm going about this all wrong, be sure and point me in a better
direction. I have a spreadsheet that contains data from the web, and I'd like
to make it smart enough to update itself when I tell it to. I've learned a little
about the "Document" object model, and have gotten to the point where I can
browse down through all the .Document.All items and figure out which ones I
want VBA to manipulate. I can even fill in the values of web pages' text boxes
and simulate a .Click on its buttons.

But now I want to make a selection from a drop-down box. Let's say it has
a list of states on it: I want my VBA program to pick out the correct state and
convince the web page that I've chosen it. I've found the Option items that
define the possible selections, and I see that if I find the correct one and
change its Selected property to True, it shows up on the page correctly as
though I selected it myself.

But what the page doesn't do is proceed from that point as though I had
clicked on the item - that is, it shows up in the drop-down selection box,
but I can't get it to go forward from there. I've tried .Clicking on
everything I can think of (might have missed one, though), but nothing
seems to work. What am I supposed to do to get to the next step.

If there's a FAQ on this, or another forum I should post to, just point me
in the right direction. And if there's an easier way than using the
Document object model - which wouldn't surprise me - feel free to point that
out to me, too. Thanks.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 114
Default Automanipulating IE drop-down list in VBA/Excel


Bob,

The code I posted worked for me as written.

Tim

On May 8, 11:21*pm, Bob Bridges
wrote:
The object I'm working with appears to have the TypeName "HTMLSelectElement".
*I don't see the OnChange method for the select object in the DOM
documentation.

But you got me started: *There's something called fireEvent that I can use
to simulate the OnChange event by simply naming it:

* t.fireEvent("OnChange")

I'll play with it after I've gotten some sleep. *If I'm on the wrong track,
feel free to say so; I'm still discovering where all the documentation is
hiding. *Thanks.



--- "Tim Williams" wrote:
Is this a drop-down which when changed should trigger some kind of action ?
Try selecting the option and then calling the "onchange" event handler:


* Set t = IE.document.getElementById("slctColor")
* t.selectedIndex = 2
* t.onchange


--- "Bob Bridges" wrote in message
...
I'm strictly a newbie in VB; I've been programming on the mainframe for
decades but am only recently come to VBA, VBScript etc, so if you notice
that I'm going about this all wrong, be sure and point me in a better
direction. *I have a spreadsheet that contains data from the web, and I'd like
to make it smart enough to update itself when I tell it to. *I've learned a little
about the "Document" object model, and have gotten to the point where I can
browse down through all the .Document.All items and figure out which ones I
want VBA to manipulate. *I can even fill in the values of web pages' text boxes
and simulate a .Click on its buttons.


But now I want to make a selection from a drop-down box. *Let's say it has
a list of states on it: *I want my VBA program to pick out the correct state and
convince the web page that I've chosen it. *I've found the Option items that
define the possible selections, and I see that if I find the correct one and
change its Selected property to True, it shows up on the page correctly as
though I selected it myself.


But what the page doesn't do is proceed from that point as though I had
clicked on the item - that is, it shows up in the drop-down selection box,
but I can't get it to go forward from there. *I've tried .Clicking on
everything I can think of (might have missed one, though), but nothing
seems to work. *What am I supposed to do to get to the next step.


If there's a FAQ on this, or another forum I should post to, just point me
in the right direction. *And if there's an easier way than using the
Document object model - which wouldn't surprise me - feel free to point that
out to me, too. *Thanks.- Hide quoted text -


- Show quoted text -


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
Drop down list dependant on previous drop down list Tenacioushail Excel Discussion (Misc queries) 1 July 1st 08 11:35 AM
Drop Down List choice selecting another drop down list CVD0722 Excel Worksheet Functions 3 October 31st 06 01:02 PM
How to Create a macro from drop down list (Validation List) in excel [email protected] Excel Programming 0 October 31st 06 12:42 PM
My Excel drop-down list eliminates from list options chosen. Help Sybil Excel Programming 2 January 19th 06 09:19 PM
multiple select from the drop down list in excel. list in one sheet and drop down in sriramus Excel Discussion (Misc queries) 5 October 27th 05 06:55 PM


All times are GMT +1. The time now is 03:00 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"