By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,842 Members | 2,198 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,842 IT Pros & Developers. It's quick & easy.

Controlling combobox in Internet Explorer

BHo15
100+
P: 135
I'm having trouble controlling a combobox in Internet Explorer. I've done it before by using IE.Document.getElementByID("controlName").Selected Index = 2, and then IE.Document.getElementByID("controlName").FireEven t ("onchange"). But... that is not working this time. I keep getting error 438 on the .SelectedIndex line.

Here is a pared down version of my code...

Expand|Select|Wrap|Line Numbers
  1. Public Sub StockChartsTrades()
  2.     Dim IE As Object
  3.         Set IE = CreateObject("InternetExplorer.Application")
  4.         IE.Visible = True
  5.     Dim IEDoc As Object
  6.  
  7.     IE.Navigate "https://stockcharts.com/login/"
  8.     Set IEDoc = IE.Document.All("form_UserID")
  9.     IEDoc.Value = "MyUserName"
  10.     Set IEDoc = IE.Document.All("form_PW")
  11.     IEDoc.Value = "MyPassword"
  12.     IE.Navigate "https://stockcharts.com/def/servlet/ScanUI"
  13.     Set IEDoc = IE.Document.All("selectScan") 'This is the combobox
  14.     IEDoc.SelectedIndex = 2 'Code throws error 438 here
  15.     IEDoc.FireEvent ("onchange")
  16.  
  17.     Set IEDoc = Nothing
  18.     Set IE = Nothing
  19. End Sub

Here is the HTML from around this combobox...

Expand|Select|Wrap|Line Numbers
  1. <div id="scc-scanengine-head">
  2.      <!-- SELECT ALERT -->
  3.      <div class="form-item" id=selectScan">
  4.           <div class ="form-item-label">...</div>
  5.           <div class="selectric-wrapper selectric-selectric-scc">
  6.           <div class="selectric-hide-select">...</div>
  7.           <div class="selectric">
  8.                <span class="label">- Your Favorite Scans -</span>
  9.                <button type="button">...</button>
  10.           </div>
  11.           <div tabindex="-1" class="selectric-items">...</div>
  12.           <input tabindex="0" class="selectric-input" />
  13.      </div>
  14. </div>
  15. <!-- LIST ACTIONS -->
  16. <ul class="scanalert-actions">...</ul>
  17. </div>
  18.  
My apologies if the HTML is a bit botched. I typed it myself since I couldn't figure out how to copy it.

So... Why am I getting error 438 when trying to set the SelectedIndex?
Dec 31 '18 #1
Share this Question
Share on Google+
3 Replies


NeoPa
Expert Mod 15k+
P: 31,306
In order to copy the HTML of a page in IE simply right-click and select View Source. That gives you selectable text.

No idea on your actual question as it needs someone who works in IE I expect.
Dec 31 '18 #2

BHo15
100+
P: 135
Thanks NeoPa. I was using Inspect and not View Source. That did the trick.

So, here is the unadulterated HTML...

Expand|Select|Wrap|Line Numbers
  1.         <div id="scc-scanengine-head">
  2.             <!-- SELECT ALERT -->
  3.             <div id="selectScan" class="form-item">
  4.                 <div class="form-item-label"><strong>Your Saved Scans</strong></div>
  5.                 <select id="favScans" class="selectric-scc" name="favScans" onchange="doLoadScan()">
  6.   <option value="default" selected="selected">- Your Favorite Scans -</option>
  7.       <option value="1798045" >3-01-01 Owned Scan</option>
  8.       <option value="1002282" >300-005 All Stocks that can be Purchased in PIA 1-14-2013</option>
  9.       <option value="1186206" >300-005 Buy Signal Scan 2015-05-06 #01-#05</option>
  10.       <option value="1005424" >300-006 All PIA Securities that had 8EMA-18SMA Cross 1-20-2014</option>
  11.       <option value="998271" >400-001 Sell Signal Active Portfolios - Bearish 50-Day Moving Average Cross</option>
  12.       <option value="998268" >400-001 Sell Signal Active Portfolios - Bearish MACD Crossover</option>
  13.       <option value="1001469" >400-003 Current Potentially Unhealthy Securities (<200D SMA) in Active Portfolios</option>
  14.       <option value="1001471" >400-003 Current Potentially Unhealthy Securities (<50 & 200D SMA) in Active Portfolios</option>
  15.       <option value="1001468" >400-003 Current Potentially Unhealthy Securities (<50D SMA) in Active Portfolios</option>
  16.       <option value="1302706" >AEH3</option>
  17.       <option value="1334840" >Custom MarketSmith 5-17-2016</option>
  18.       <option value="1320273" >EMA x SMA</option>
  19.       <option value="1340364" >Green Line Trading 5-30-2016</option>
  20.       <option value="1411269" >Industry Analysis - Bottom 11-8-2016</option>
  21.                 </select>
  22.             </div>
  23.  
  24.             <!-- LIST ACTIONS -->
  25.             <ul class="scanalert-actions">
  26.                 <li class="rename"><a id="rename-link" data-toggle="modal" href="#renameModal"><span class="fa-stack fa-lg"><i class="fa fa-circle fa-stack-2x"></i><i class="fa fa-eraser fa-stack-1x fa-inverse"></i></span><span class="hide-xs">Rename</span></a></li>
  27.                 <li class="save"><a href="javascript:doSaveScan();"><span class="fa-stack fa-lg"><i class="fa fa-circle fa-stack-2x"></i><i class="fa fa-download fa-stack-1x fa-inverse"></i></span><span class="hide-xs">Save</span></a></li>
  28.                 <li class="saveas"><a href="javascript:doAddModifyScan();"><span class="fa-stack fa-lg"><i class="fa fa-circle fa-stack-2x"></i><i class="fa fa-pencil-square-o fa-stack-1x fa-inverse"></i></span><span class="hide-xs">Save As</span></a></li>
  29.                 <li class="delete"><a href="javascript:doRemoveScan();"><span class="fa-stack fa-lg"><i class="fa fa-circle fa-stack-2x"></i><i class="fa fa-trash fa-stack-1x fa-inverse"></i></span><span class="hide-xs">Delete</span></a></li>
  30.                 <li class="viewall"><a href="javascript:doViewAll();"><span class="fa-stack fa-lg"><i class="fa fa-circle fa-stack-2x"></i><i class="fa fa-eye fa-stack-1x fa-inverse"></i></span><span class="hide-xs">View All</span></a></li>
  31.             </ul>
  32.         </div><!-- end of SCANENGINE HEAD -->
Dec 31 '18 #3

BHo15
100+
P: 135
I see from the HTML I pasted that there is an ID "favScans" which actually has the choice options listed below it (I did not see that one when I was working with it). I just tried the code with using favScans instead, but it would not let me interact with that element at all (error 70 Permission DENIED!!!).
Dec 31 '18 #4

Post your reply

Sign in to post your reply or Sign up for a free account.