VBA to navigate ie and select from a combobox

vdl10

New Member
Joined
May 8, 2014
Messages
1
The purpose of my code is to navigate to a web page (intranet), log in, click on some links and finally reach a page where I can select "Edit" from a combobox that will then give me a popup in (java?) where I can edit the division. The combobox values seem to dynamically change based off of a previous selection yet there are always three choices. The combobox has three choices:
1) Division currently selected
2) Clear
3) Edit



This is my code so far

Code:
Sub gettable()
     Dim ieApp As InternetExplorer
     Dim ieDoc As Object
     Dim WaitTime As Integer
     Dim Popup As Object
     Dim hwnd As Long
     Dim HTMLdoc As HTMLDocument
     'Dim ieTable As Object
     'Dim clip As DataObject
     
     
     Set ieApp = New InternetExplorer
     
    
     ieApp.Visible = True

     'assume we're not logged in and just go directly to the login page'
     ieApp.Navigate "Website"
     Do While ieApp.Busy: DoEvents: Loop
     Do Until ieApp.ReadyState = READYSTATE_COMPLETE: DoEvents: Loop
     Set ieDoc = ieApp.document
          
     On Error GoTo ErrHandler
         'fill in the login form - View Source from your browser to get the control names
     With ieApp.document.forms(0)
         .j_user.Value = "Username"
         .j_Password.Value = "Password"
         .submit
     End With
     Do While ieApp.Busy: DoEvents: Loop
     Do Until ieApp.ReadyState = READYSTATE_COMPLETE: DoEvents: Loop
    
'if already logged in skips login
ErrHandler:
       
     ieApp.Navigate "Website that can be loaded once signed in"
     
     Do While ieApp.Busy: DoEvents: Loop
     Do Until ieApp.ReadyState = READYSTATE_COMPLETE: DoEvents: Loop
     For Each Link In ieDoc.Links
        If Link.innerText = "OK" Then Link.Click
     Next Link
     

'I had to loop until the website url became a different url because ie stops running but something in (java?) is running and causes the site to change after a couple of seconds'
     Do While ieApp.Busy: DoEvents: Loop
     Do Until ieApp.LocationURL = "Final Webpage": DoEvents: Loop
     Do Until ieApp.ReadyState = READYSTATE_COMPLETE: DoEvents: Loop

'From this page, I needed to click on a link called filter which would let me then change some values from different comboboxes'
     For Each Link In ieDoc.Links
     If Link.innerText = "Filter" Then Exit For
     Next Link
     Link.Click
     Do While ieApp.Busy: DoEvents: Loop
     Do Until ieApp.ReadyState = READYSTATE_COMPLETE: DoEvents: Loop
    
  'This is where my code get stuck'   
    
ieDoc.getElementById("FILTER_PANE_ac_unid5_dropdown_combobox").Focus
'ieDoc.getElementById("FILTER_PANE_ac_unid5_dropdown_combobox-r").SelectedIndex = 2

 
End Sub




This is the html code associated with the combobox in question
Changing the value of the comboxbox and using the onfire event doesnt work either. The page will reload to the exact same page where it was before I changed the value of the combox. Using selectedindex give me Error 438 the object doesnt support method

Btw, I am using IE9

HTML:
<td class="urLayoutDefault">
<span class="urCoB2Whl" id="FILTER_PANE_ac_unid5_dropdown_combobox-r" onmousedown="sapUrMapi_ComboBox_mousedown('FILTER_PANE_ac_unid5_dropdown_combobox',event);" *******="sapUrMapi_ComboBox_click('FILTER_PANE_ac_unid5_dropdown_combobox',event);" onsc="sapbi_acComboBox_callCustomScript([['BI_ADVANCED','FILTER_PANE_ac_unid5_dropdown',0],['BI_COMMAND_TYPE','SELECTION_CHANGED',0],['TARGET_ITEM_REF','FILTER_PANE',0],['CONTROLID','FILTER_PANE_ac_unid5_dropdown_combobox',0],['EVENT',event,0]],event);">

<input tabIndex="0" class="urCoB2TxtDdl" id="FILTER_PANE_ac_unid5_dropdown_combobox" style="width: 17ex;" onkeydown="sapUrMapi_ComboBox_keydown('FILTER_PANE_ac_unid5_dropdown_combobox',event);" onkeypress="sapUrMapi_ComboBox_keypress('FILTER_PANE_ac_unid5_dropdown_combobox',event);" onfocus="sapUrMapi_ComboBox_focusDdlb('FILTER_PANE_ac_unid5_dropdown_combobox',event);" onblur="sapUrMapi_ComboBox_blurDdlb('FILTER_PANE_ac_unid5_dropdown_combobox',event);" onselectstart="ur_EVT_cancel('FILTER_PANE_ac_unid5_dropdown_combobox',event);" readOnly="" ct="CB" ti="0" st="" tp="DD" ic="2" vs="Show All Values" vt="true" op="false" lid="FILTER_PANE_ac_unid5_dropdown_itemlistbox" ks="current" k="current" value="Show All Values"/>

<input tabIndex="-1" class="urCoB2Btn" id="FILTER_PANE_ac_unid5_dropdown_combobox-btn" type="text" readOnly=""/>

<div class="urCob2Ilb" id="FILTER_PANE_ac_unid5_dropdown_itemlistbox-r">
***** style="display: none;">
Text - <span id="FILTER_PANE_ac_unid5_dropdown_itemlistbox" st="" class="urCob2Box" ***********="me.sapUrMapi_ItemListBox_mouseover('FILTER_PANE_ac_unid5_dropdown_itemlistbox',document,event);" *******="me.sapUrMapi_ItemListBox_click('FILTER_PANE_ac_unid5_dropdown_itemlistbox',document,event);" onfocus="me.sapUrMapi_ItemListBox_focus('FILTER_PANE_ac_unid5_dropdown_itemlistbox',document,event);" onselectstart="me.ur_EVT_cancel('FILTER_PANE_ac_unid5_dropdown_itemlistbox',event);" style="width:10px;height:0;"><table cellspacing="0" cellpadding="0" width="100%" multi="false" pop="true" w="0" h="0" v="10" s="2" vcol="1" cols="1"><tbody><tr k="current" class="urIlb2ISel"><td class="urCob2I">Show All Values</td></tr><tr k="edit"><td class="urCob2I">Edit</td></tr></table></span>
 
Last edited:

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
ieDoc.getElementById("FILTER_PANE_ac_unid5_dropdown_combobox-r").SelectedIndex = "2"

Parentheses
 
Upvote 0

Forum statistics

Threads
1,215,650
Messages
6,126,012
Members
449,280
Latest member
Miahr

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