title: vbscript capture text in the html select option tag
body: <p>I've looked through all other questions, plus many searches over the internet, and cannot find anything that works with my situation.</p>
  
  <p>I have a macro that was developed in VBScript for IBM Personal Communications (PCOMM). My bosses want me to convert it so it can be used in Macro Express Pro (ME). ME is a WYSIWYG (what you see is what you get) editor that has preset functions and allows for external scripting of JScript, VBScript, and HTA.</p>
  
  <p>The PCOMM macro is about 1000 lines of pure VBScript, so it only makes sense to keep it that way, however ME doesn't allow some things that PCOMM does, so some modifications need to be made.</p>
  
  <p>One modification is there already is one global instance of Internet Explorer (IE), so the macro has been designed to use that instance. I'm trying to get the selected option of a drop down box, but everything I've tried has been unsuccessful.</p>
  
  <p>Here's the HTML code:</p>
  
  <pre><code>&lt;select name="ctl00$cphContent$ddlWorkQueue" onchange="javascript:setTimeout('__doPostBack(\'ctl00$cphContent$ddlWorkQueue\',\'\')', 0)" id="ctl00_cphContent_ddlWorkQueue" class="ddlbox"&gt;
      &lt;option selected="selected" value="5422"&gt;605&lt;/option&gt;
      &lt;option value="5419"&gt;ACCUM&lt;/option&gt;
      &lt;option value="5418"&gt;CORRESPONDENCE&lt;/option&gt;
      &lt;option value="5415"&gt;FEKEY&lt;/option&gt;
      &lt;option value="5416"&gt;NKPORTAL&lt;/option&gt;
      &lt;option value="5420"&gt;PROVIDER&lt;/option&gt;
      &lt;option value="5423"&gt;EDITS&lt;/option&gt;
      &lt;option value="5421"&gt;TRACR&lt;/option&gt;
      &lt;option value="5417"&gt;WAND&lt;/option&gt; 
  &lt;/select&gt;
  </code></pre>
  
  <p>As you can see, "605" is selected. I want to be able to display "605" in a message box. Here's the VBScript for this:</p>
  
  <pre><code>'This subroutine checks to see if the selected queue matches the ini value if it does not it updates the ini value
  Sub SetQueue
      Dim Selection
  
      'Commented out by previous developer.  We do not want to create a new instance of Internet Explorer.  We want to use the existing instance...
      'Set objIE = CreateObject("InternetExplorer.Application")
  
      Selection = Document.getElementById("ctl00_cphContent_ddlWorkQueue").selectedIndex
      MsgBox "Selection: " &amp; Selection
  End Sub
  </code></pre>
  
  <p>Hopefully someone can offer me some assistance and point me in the right direction. All I get when I run the macro is "Selection:    ".</p>