vba changing the selection in a html dropdown menu

Munch01

New Member
Joined
Nov 11, 2014
Messages
1
Hi all,

I am trying to change the selection in a html dropdown menu within a form with <acronym title="visual basic for applications" style="border-width: 0px 0px 1px; border-bottom-style: dotted; border-bottom-color: rgb(0, 0, 0); cursor: help; color: rgb(51, 51, 51); background-color: rgb(250, 250, 250);">vba</acronym> in order to collect information.

webpage:
http://www.sea-distances.org/

Here is what I have:

Code:
Dim IE As Object


Set IE = CreateObject("InternetExplorer.Application") 'Set IE = InternetExplorer
IE.Visible = True 'Set InternetExplorer to Visible
IE.Navigate "http://www.sea-distances.org/" 'Load web page


'Run and Wait, if you intend on passing variables at a later stage
Do While IE.Busy
    DoEvents
Loop
Do While IE.readyState <> 4
    DoEvents
Loop


IE.document.getElementById("country_id_from").Focus
IE.document.getElementById("country_id_from").selectedIndex = 1
IE.document.getElementById("country_id_from").FireEvent ("onchange")

The HTML:
HTML:
	<form class="form-vertical" id="verticalForm" action="/" method="post">		<div class="span6">		<div class="row">			<div class="port span3 pull-left" id="pfrom2">				<h4>Port of Departure</h4>				<label>Country</label>				<select class="span3" name="country_id_from" id="country_id_from"><option value="">select country</option><option value="0001" data-image="/flags/blank.gif" data-imagecss="eflag f1">Albania</option><option value="0002" data-image="/flags/blank.gif" data-imagecss="eflag f2">Algeria</option><option value="0004" data-image="/flags/blank.gif" data-imagecss="eflag f4">Angola</option><option value="0005" data-image="/flags/blank.gif" data-imagecss="eflag f5">Antigua</option><option value="0006" data-image="/flags/blank.gif" data-imagecss="eflag f6">Argentina</option><option value="0007" data-image="/flags/blank.gif" data-imagecss="eflag f7">Aruba</option>

Problem: The dropdown menu dos't change.
Thanks for your help
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.

Forum statistics

Threads
1,223,264
Messages
6,171,081
Members
452,377
Latest member
bradfordsam

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top