Using the Selected Index

User avatar
HansV
Administrator
Posts: 78545
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Using the Selected Index

Post by HansV »

I have to admit that I don't know how these things work.
Best wishes,
Hans

User avatar
jscher2000
2StarLounger
Posts: 148
Joined: 26 Dec 2010, 18:17

Re: Using the Selected Index

Post by jscher2000 »

agibsonsw wrote:But isn't it the JavaScript interpreter of the browser that translates/actions the 'fireEvent' function?
I don't think so in this case. The COM object version of IE exposes a VB interface, so VB rules apply.

User avatar
Joseph
3StarLounger
Posts: 206
Joined: 31 Dec 2010, 22:23
Location: Columbia Falls, MT

Re: Using the Selected Index

Post by Joseph »

I have all objects on the page active at this point, utilizing sendkeys.

However, after using the sendkeys, I can't select the objects....

Code: Select all

Private Sub CommandButton1_Click()
Dim IE As Object

Set IE = CreateObject("internetexplorer.application")
   
With IE
        .Visible = True
        .navigate ("http://rlgwsweb01h1.roadlink.net:90/reports/loadbylocation2rebate_DataT.aspx")
        While .Busy Or .readyState <> 4: DoEvents: Wend
        
'set location
        Set L = .document.all("ctl00_cphMain_ddlLocation")
  
'set department
        Set D = .document.all("ctl00_cphMain_lbDepartment")
        
'set rate group
        Set R = IE.document.getElementById("ctl00_cphMain_lbRateGroup")
  
'set from date
        Set F = .document.all("ctl00_cphMain_txbFromDate")
  
'set to date
        Set T = .document.all("ctl00_cphMain_txbToDate")
  

  
'Activate all Objects Within Data Report
        
       L.Focus
       SendKeys "{UP}", True
       
'- delay 1 second, will not work without
    On Error Resume Next
        Application.Wait Now + TimeValue("00:00:01")
        
            SendKeys "{TAB}", True
            SendKeys "{DOWN}", True
            
    ' All objects are now active, but am not able to further navigate. The below code yeilds no results.
    
' Fill in Department
            D.Focus
            D.Value = "284"
Am I missing something?

User avatar
jscher2000
2StarLounger
Posts: 148
Joined: 26 Dec 2010, 18:17

Re: Using the Selected Index

Post by jscher2000 »

I think SendKeys is a bumpy road to a bad place.

I created a very simple example of manipulating a select control in VBA, targeting a simple sample page. Perhaps it will be helpful in thinking about how to move forward. Please see the attached.

Edit: You might want to play with the page first to see what it does: http://dev.jeffersonscher.com/dom/select-controls.html" onclick="window.open(this.href);return false;
You do not have the required permissions to view the files attached to this post.

User avatar
Joseph
3StarLounger
Posts: 206
Joined: 31 Dec 2010, 22:23
Location: Columbia Falls, MT

Re: Using the Selected Index

Post by Joseph »

That works...thanks!!