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

Need help with IE selecting drop down

BHo15
100+
P: 142
I am trying to select from a dropdown in IE from Access VBA. You cannot right click on the dropdown and inspect element. I ended up using something on found online, and it worked for a while, but it has now stopped working. Here is what I was using...

Expand|Select|Wrap|Line Numbers
  1. IEWindow.Document.querySelector("div[id=pagecontents] div[class=container] div[id=resultOptions] form[name=resultOptions] select[id=selectResult]").Focus
  2. IEWindow.Document.querySelector("div[id=pagecontents] div[class=container] div[id=resultOptions] form[name=resultOptions] select[id=selectResult]").selectedIndex = 4
  3. IEWindow.Document.querySelector("div[id=pagecontents] div[class=container] div[id=resultOptions] form[name=resultOptions] select[id=selectResult]").dispatchEvent evt
If I remember correctly, the error that occured is that it could not find the object (presumably the IE control that is referenced).

I then found another way to find that dropdown, and it appears that it is a control called selectResult (see the HTML below).

Expand|Select|Wrap|Line Numbers
  1. <div id="page-header">_</div>
  2. <!-- end of PAGE HEADER -->
  3. <-- PAGE CONTENTS -->
  4. <div id="pagecontents">
  5.    <div class="container">
  6.        <div class="panel panel-default scc-scanengine-panel" id="scc-scanengine-criteria">_</div>
  7.        <div id="resultOptions">
  8.           <form name="resultOptions">
  9.              <span class="form-item-label">Available Actions</span>
  10.              <select id="selectResult">
  11.                 <option selected="selected" value="none">- Choose -</option>
  12.                 <option value="new">Store these results in a new C_</option>
  13.                 <option value="merge">Merge these results with an ex_</option>
  14.                 <option value="replace">Replace an existing ChartList _</option>
  15.                 <option value="csv">Download In CSV Format</option>
  16.              </select>
  17.           </form>
  18.         </div>
  19.         <script type = "text/javascript">,!-- var sortOrder = "USAD"; _</script>
  20.         <form name="submitForm" action="/def/servlet/SC.uscan" method="post">_</form>
  21. <!-- TABLE DATE ROW -->
  22. <div class="dt-date-row">_</div>
  23. </div>
For those that are good at HTML... Please don't shoot me. I had a screen print of the HTML, and then I tried to type it out.

So... The problem is that I am having trouble connecting to the IE control (the dropdown box). Then, when I connect to it, I need to be able to select the csv option (which I'm assuming is option 4 if zero based).

Thoughts?
3 Weeks Ago #1
Share this Question
Share on Google+
10 Replies


BHo15
100+
P: 142
I lot of views on this? Anyone able to help?
3 Weeks Ago #2

NeoPa
Expert Mod 15k+
P: 31,470
Unlikely I would expect. The numbers of Access programmers who have experience controlling IE from VBA is probably very small relatively. I'm only surprised you seem to expect otherwise.

Good luck and all, but I can't hold out a great deal of hope in the circumstances.
3 Weeks Ago #3

BHo15
100+
P: 142
Oh well. It was a good thought.
3 Weeks Ago #4

NeoPa
Expert Mod 15k+
P: 31,470
Never hurts to try. Just bear in mind this is an Access forum so is likely to have mainly Access people reviewing it.

It's not impossible that some might have the experience you need but it's necessarily going to be a small fraction of those here.
3 Weeks Ago #5

BHo15
100+
P: 142
Iíve been working in Access for about 15 years, and though itís rare, I have had need to write VBA FOR IE, so I was just hoping that others did as well. Bytes is my favorite message board for Access and VBA. So I always like to start here.
3 Weeks Ago #6

NeoPa
Expert Mod 15k+
P: 31,470
Makes good sense. Just don't be too disappointed when you find you're now that expert ;-)
3 Weeks Ago #7

Rabbit
Expert Mod 10K+
P: 12,364
Seeing as how you there's an id, you can use the more straightforward getElementById() function instead of querySelector().
3 Weeks Ago #8

BHo15
100+
P: 142
Yes sir, I tried that, and it is still not connecting correctly. It keeps saying "object required".
3 Weeks Ago #9

Rabbit
Expert Mod 10K+
P: 12,364
Try running Access as an admin. I've noticed that trying to script IE will tend to disconnect from the object unless I'm running the script as admin
3 Weeks Ago #10

BHo15
100+
P: 142
Interesting Rabbit. I never would have guessed that. I'll give it a go.
2 Weeks Ago #11

Post your reply

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