View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Tim Williams Tim Williams is offline
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.