VBA code to select drop down item from webpage

Kenpachigo

New Member
Joined
Feb 17, 2019
Messages
1
Hello everybody,

Usually, I look for solutions on the internet and step by step try to understand what is happening so I can adjust the code to fit my needs. But in this case, I am kinda stuck.
Problem:I want to fill in a web form using VBA code. I can fill in some text fields, select a radio button etc... But the dropdown list is giving me headaches.

I have found some code which seems to (only) highlight the item that I want. But it's only visible when I click on the drop down box. And it seems like that it's not actually clicking/loading that value. When the option is highlighted (by my code), I also cannot click on anything else anymore. Normally, the second drop down box would appear when the first category is selected.





Code:
Sub FillInWebform()    

    Set IE = CreateObject("InternetExplorer.Application")
    IE.Visible = True
    IE.navigate "https://www.2dehands.be/plaats/"
    Application.StatusBar = "Submitting"
    
    While IE.Busy
        DoEvents
    Wend
    
     IE.document.getElementById("manual-option").Click 'clicking on the radio button to show the drop down field


    Set Title = IE.document.getElementById("level1-option")
    Title.selectedIndex = 40
    
    Set Title = IE.document.getElementById("price")
    Title.selectedIndex = 1
    
   


    IE.Quit
    Set IE = Nothing



End Sub


Here is the image on google foto containing HTML code and part of the webform:
HZLtSyJQB4cApRC87
HZLtSyJQB4cApRC87

https://photos.app.goo.gl/HZLtSyJQB4cApRC87
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.

Forum statistics

Threads
1,223,270
Messages
6,171,102
Members
452,379
Latest member
IainTru

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