IE automation -- select item from list

leaftye

New Member
Joined
Dec 13, 2005
Messages
21
How do I select "AZ" from the list this code would generate:

Code:
<select name="delstate" size="1" tabindex="8">
  <option >CA</option>
  <option  >AZ</option>
  <option  >NV</option>
  <option  >OR</option>
  <option  >WA</option>
</select>

I'm wishing this to work without luck:
Code:
Set IEapp = CreateObject("InternetExplorer.Application")
IEapp.Document.all.Item("delstate").Value = "AZ"

I could use SendKeys, but would rather not.

Eugene
 

Some videos you may like

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
L

Legacy 98055

Guest
The options collection of the HTMLSelectElement is zero based. Therefore, the index of 1 is actually the second option. To select the second option, "AZ", use this code:

Code:
ieapp.document.all.Item("delstate").selectedIndex = 1

Tom
 

Watch MrExcel Video

Forum statistics

Threads
1,118,110
Messages
5,570,250
Members
412,313
Latest member
pauloalex
Top