title: VBA: Select index IE lists
body: <p>Long time reader and first time poster.  I'm a little stuck with why I can't seem to select an index from a dropdown list from IE using this VBA code:</p>
  
  <pre><code>    IE.document.getElementById("ddlReportTemplate").Focus
      IE.document.getElementById("ddlReportTemplate").selectedIndex = 23
      IE.document.getElementById("ddlReportTemplate").FireEvent ("onchange")
  </code></pre>
  
  <p>Here is the source code:</p>
  
  <pre><code>&lt;select name="ddlReportTemplate" class="inputControl" id="ddlReportTemplate" style="width: 308px;" onchange="OnReportTemplateSelectionChanged(event)" autocomplete="off"&gt;
  &lt;option selected="selected" value="-1"&gt;Please select...&lt;/option&gt;
  &lt;option value="21"&gt;Action Closeout Report&lt;/option&gt;
  &lt;option value="19"&gt;Action Status Report&lt;/option&gt;
  &lt;option value="8"&gt;Bi Monthly Report HAZID&lt;/option&gt;
  &lt;option value="7"&gt;Bi Monthly Report HAZOP&lt;/option&gt;
  &lt;option value="23"&gt;Combined Action Summary (Dashboard)&lt;/option&gt;
  &lt;option value="20"&gt;Design Review Dump&lt;/option&gt;
  &lt;option value="11"&gt;HAZOP Action Sheet Population&lt;/option&gt;
  &lt;option value="22"&gt;HAZOP Data Dump&lt;/option&gt;
  &lt;option value="18"&gt;NCOC Actions Closed this week (since 01/01/16)&lt;/option&gt;
  &lt;option value="17"&gt;NCOC Actions Opened/Re-opened (since 01/01/16)&lt;/option&gt;
  &lt;option value="13"&gt;NCOC Project Action Status&lt;/option&gt;
  &lt;option value="6"&gt;Pisys Test&lt;/option&gt;
  &lt;option value="27"&gt;PM660&lt;/option&gt;
  &lt;option value="5"&gt;Project Action Overdue Report&lt;/option&gt;
  &lt;option value="25"&gt;Shell GPS 'live' actions&lt;/option&gt;
  &lt;option value="9"&gt;Test&lt;/option&gt;
  &lt;option value="15"&gt;Weekly update&lt;/option&gt;
  &lt;option value="10"&gt;WEL PSP Report dump&lt;/option&gt;
  &lt;option value="24"&gt;Workpack Specific&lt;/option&gt;&lt;option value="26"&gt;workpack 073&lt;/option&gt;
  </code></pre>
  
  <p></p>
  
  <p>I've also tried </p>
  
  <pre><code>With IE
      While .Busy Or .readyState &lt;&gt; 4: DoEvents: Wend
      IE.document.getElementByName("ddlReportTemplate")(0).Value = 23
      IE.document.getElementByName("ddlReportTemplate").FireEvent ("onchange")
  
  End With
  </code></pre>
  
  <p>and I have defined IE as an object for IE and it opens the website already.</p>
  
  <p>Not sure where the issue is, but I'm hoping someone on here will be a legend and find a solution to this.</p>
  
  <p>Thanks :)</p>
  
  <p>PS: Unfortunately I can't post the web address since it's company sensitive.  </p>