Select value in html dropdown with vba

Jacob Lemming

New Member
Joined
Jan 29, 2015
Messages
5
I’m trying to select a value on the html dropdown box with excel vba code (as far as I know the html is javascript) but I’m not good at html.
I have tried every possible proposal from various forums, without luck.
The web page is an internal company page, so unfortunately it cannot be shared.
The dropdown box is Tagname ("select"), I can enter a value with sendkey, but it is not selected.
When the right value is selected there are several dropboxes that changing options depending on the value.

someone who has an idea?

I got this:

Code:
Set IE = New InternetExplorerMedium
IE.Visible = True
URL =”xxx”
For Each htmlInput In IE.document.all 
   While IE.Busy Or IE.readyState < 4:  DoEvents:  Wend
   Select Case htmlInput.ID
      Case Country:
      Call WriteHtmlInput(htmlInput, "43.") 
    ….
 
 
Sub WriteHtmlInput(htmlInput As MSHTML.HTMLInputElement, txt As String)
Dim TimeWaitShort As String
Dim TimeWaitLong As String
 
TimeWaitShort = "0:00:02"
TimeWaitLong = "0:00:04"
   
Debug.Print "Tagname: " & htmlInput.tagName & " Tekst: " & txt & "  ID: " & htmlInput.ID
Select Case htmlInput.tagName
  Case "INPUT":   ' f.eks title
    htmlInput.Focus
    Application.Wait (Now + TimeValue(TimeWaitShort))
    htmlInput.Value = txt
  Case "DIV
    Application.Wait (Now + TimeValue(TimeWaitLong))
    htmlInput.textcontent = txt
  Case "SELECT":  'f.eks dropdown
     htmlInput.Focus
    ?????
     Application.Wait (Now + TimeValue(TimeWaitLong))
  Case Else
     Debug.Print "Æv der er sket en fejl"
  End Select
End Sub
 
Last edited by a moderator:

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
please share the links to the sites where you have already posted. One of the forum rules is to not cross post without at least giving the members here the opportunity to understand what responses you have already had
 
Upvote 0
then i apologise for misreading your initial post
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,246
Members
452,623
Latest member
cliftonhandyman

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