VBA + JavaScript + IE = Help!

zach454

New Member
Joined
Apr 25, 2011
Messages
28
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:

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
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
This is the area in HTML that I believe refers to the cell.

HTML:
<td id="GridEX1rt30_L" valign="top" class="custom1_cell_GridEX1rt30"><span class="custom1_cell_GridEX1rt30_c"> </span></td><td id="GridEX1rt31_L" valign="top" class="custom1_cell_GridEX1rt30"><span class="custom1_cell_GridEX1rt30_c"> </span></td><td id="GridEX1rt32_L" valign="top" class="custom1_cell_GridEX1rt30"><span class="custom1_cell_GridEX1rt30_c"> </span></td><td id="GridEX1rt33_L" valign="top" class="custom1_cell_GridEX1rt30"><span class="custom1_cell_GridEX1rt30_c"> </span></td>



This is the function I'm trying to call...........
Code:
function ProcessStatusChange(cell) {
		var vOperationID = cell.getValue();
		var objRow = cell.getRow();
		var sBackColor;
		var objTargetCell;
		var sRemainingQty;
 
Upvote 0

Forum statistics

Threads
1,215,265
Messages
6,123,961
Members
449,135
Latest member
jcschafer209

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