Selecting a dropdown in navigating site via vba

Nelson78

Well-known Member
Joined
Sep 11, 2017
Messages
526
Office Version
  1. 2007
Hello everybody.

I'm struggling with some problems in selecting a dropdown navigating in Explorer via vba.

Above the code, until it works:

Code:
sub enter_site ()

 
Dim myId As String, myCode As String

myId = Range("E9")                   'user'
myCode = Range("F9")               'pw'
myURL = "https://aaa/bbb/Authentication/Login.aspx"

Set IE = CreateObject("InternetExplorer.Application")

With IE
    .navigate myURL
    .Visible = True
    Do While .Busy: DoEvents: Loop    'Attesa not busy
    Do While .readyState <> 4: DoEvents: Loop 'Attesa documento
End With

myStart = Timer

Do  
    DoEvents
    If Timer > myStart + 1 Or Timer < myStart Then Exit Do
Loop


IE.document.getElementById("UserName").Value = myId
IE.document.getElementById("Password").Value = myCode

Set mycoll = IE.document.getElementsByTagName("Input")
For Each myinp In mycoll
   
    If myinp.ID = "LoginButton" Then
        myinp.CLICK
        Exit For
    End If

Next myinp


    Do While IE.Busy: DoEvents: Loop    'Attesa not busy'
    Do While IE.readyState <> 4: DoEvents: Loop 'Attesa documento'

IE.document.getElementById("menu").CLICK
IE.document.getElementById("report").getElementsByTagName("a")(4).CLICK

Now, i've a dropdown to select.

Above the html code:


HTML:
<select id="site" title="listsites" onchange="javascript:setTimeout('__doPostBack(\'site\',\'\')', 0)" name="site">
<option value="0" selected="selected">Select</option>
<option value="1">London1</option>
<option value="2">London2</option>
<option value="3">Brighton</option>
<option value="4">London3</option>


Maybe for the intrinsic caracteristic of the page (aspx), I can't proceed. I've tried selecting by id and also with Sendkeys, with no positive results.


Could you get me some hints, please?
 
Hi, I got error 328 at above line. Much appreciated if you could help!
Please start a new thread, describing exactly what you are attempting, including the URL of the web site. Post your code and indicate where the error occurs and the exact error message, not just the error number.
 
Upvote 0

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop

Forum statistics

Threads
1,223,231
Messages
6,170,885
Members
452,364
Latest member
springate

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