I'm struggling to understand how to control a javascripted webpage via Excel VBA. I have this page for work (on WAN) and I can get VBA to pull the page up and display they table I want but I am unable to click on the dropdown menu. When I use the .click (objcollection.click) it will highlight the cell but it won't display the dropdown. So I debugged the webpage and noticed that it appears to be controlled by javascript. But I can't engage them? I also tried .fireevents, but it doesn't seem to work. Only thing I can think of is I need so point to where the function of javascript is at?? I also noticed the website has a Janus GRIDEX in which these dropdowns are in. Could someone please help me figure this out, I would really appreciate a point in the right direction. VBA Code below:
Please Help me!!
Thanks
Code:
Dim IE As Object
' Create InternetExplorer Object
Set IE = CreateObject("InternetExplorer.Application")
'Get Id
For i = 1 To NumWorkCenters
If WorkCenters(i) = Prompt.WorkCenterCOMBO.Value Then
ID = wcSIS(i)
Exit For
End If
Next i
' You can uncoment Next line To see form results
IE.Visible = True
AppActivate IE
apiShowWindow IE.hwnd, SW_MAXIMIZE
' Send the form data To URL As POST binary request
IE.Navigate "website URL"
' Wait while IE loading...
Do While IE.Busy
Application.Wait DateAdd("s", 1, Now)
Loop
Set elements = IE.Document.getElementsByName("txtsearch")
If Not elements Is Nothing Then
Set nachnameValueInput = elements(0)
If Not nachnameValueInput Is Nothing Then nachnameValueInput.Value = Prompt.OrderSCAN.Value
'Auto Enter
IE.Document.getElementById("cmdGo").Click
End If
' Wait while IE loading...
Do While IE.Busy
Application.Wait DateAdd("s", 1, Now)
Loop
' 'Status - GridEX1rt37_L
' 'StatusClassName - custom1_cell_GridEXrt30
' 'FinishQTY - GridEX1rt34_L
' 'Comments - - GridEX1rt36_L
' 'Startdate - GridEX1rt32_L
' 'Finishdate - GridEX1rt33_L
' 'PlnStartDate - GridEX1rt31_L
' 'PromDate - GridEX1rt30_L
'
Set objCollection = IE.Document.getElementById("GridEX1rt37_L")
objCollection.Click '<-----Highlights cell
objCollection.Value = 1 '<------Doesn't do anything...
'Save SIS
Dim CurrentWindow As HTMLWindowProxy: Set CurrentWindow = IE.Document.parentWindow
'THESE BELOW DON'T WORK
IE.navigate ("javascript:ProcessStatusChange('custom1_cell_GridEXrt30');") '<------Appears in javascript as function ProcessStatusChange(cell) * cell is defined as what I have
Call CurrentWindow.execScript("javascript:ProcessStatusChange('custom1_cell_GridEXrt30');")
Call CurrentWindow.execScript("javascript:ProcessSaveButt*******('SAVE');") '<-------THIS WORKS
Please Help me!!
Thanks