IE button remains greyed out and won't let code "click" it

sthack99

Board Regular
Joined
May 16, 2006
Messages
237
Hi all. I have developed a code that will go to a county court website, search for a case, extract information about it, then close the site and go on to the next. I have a different sub routine that runs for each county. The problem I am having is that the current county I'm working on (Duval) will not let you click the "Open Case" button - the button remains greyed out until (I'm guessing) it detects keystrokes in the search box. Because the code populates the search box automatically, the button remains greyed out and the code hits a brick wall, so to speak. Please see if you can help me find a way around this!

Here's an example Case Number: 2013ca002119
The username and password is not shown, but it's free to create an account if you want to.

Duval county's sub code:
Code:
'Sub code for Duval county

Sub Duval(CaseNbr As String, RowNbr As Integer)

'On Error GoTo ErrHandler    'What to do if the code encounters an error.

Dim IE As Object
Dim doc As Object
Dim links As Object
Dim CaseStatus As Object
Dim itms As Object
Dim itm As Object
Dim fields As Object
Dim field As Object


Set IE = CreateObject("InternetExplorer.Application")
        
    'Go to county website
    IE.navigate "https://core.duvalclerk.com/CoreCms.aspx"
    IE.Visible = True
    Do
    DoEvents
    Loop Until IE.readyState = 4
    
    Sleep 1000
                
    Set doc = IE.Document
    
    doc.getElementByID("c_UsernameTextBox").Value = UserName  '**USERNAME HIDDEN
    doc.getElementByID("c_PasswordTextBox").Value = Password  '**PASSWORD HIDDEN
    
    Set itms = doc.getElementsByTagName("input")
    For Each itm In itms
        If itm.Type = "submit" Then
            itm.Click
            Exit For
        End If
    Next itm
    
    Sleep 3000
    
    Set itm = doc.getElementsByTagName("input")
    For Each itm In itms
        If itm.Type = "text" And itm.Value <> "1:0" Then
            itm.Value = CaseNbr
            Exit For
        End If
    Next itm
    
    Sleep 500
    
'**THIS IS WHERE IT'S GETTING STUCK**

    Set itm = doc.getElementsByTagName("input")
    For Each itm In itms
        If itm.Type = "button" Then
            itm.Click
            Exit For
        End If
    Next itm
    
    Sleep 3000
        
                             
    'Retrieve info from table
    Set CaseStatus = doc.getElementsByTagName("TABLE")(3)
    ActiveSheet.Range("I" & RowNbr).Value = CaseStatus.Rows(2).Cells(1).innertext
    
    'Since there is no visible unique URL for the docket, a copy of the docket must be saved to the user's computer
    strHTML = IE.Document.DocumentElement.innerhtml
    FileLoc = "C:\Users\sarat\Desktop\Case Status\Docket Reports\" & ActiveSheet.Range("A" & RowNbr).Value & "-Docket.html"
    Open FileLoc For Output As #1
          Print #1, strHTML
    Close #1
    
    ActiveSheet.Hyperlinks.Add Anchor:=Range("J" & RowNbr), Address:=FileLoc, TextToDisplay:="Docket"   'Link to saved docket file

       

'exithere:
'
    IE.Quit
'
'Exit Sub
'
'ErrHandler:
'    ActiveSheet.Range("I" & RowNbr).Value = "N/A"
'    ActiveSheet.Range("J" & RowNbr).Value = "N/A"
'    Resume exithere
End Sub


The button's source code:
HTML:
<INPUT *******='javascript:getCaseTabByUcnBoxId("c_UcnEntryBox_adbfe763_6470_4337_8bce_634e1985e257");' disabled id=c_SubmitCaseLookupButton_adbfe763_6470_4337_8bce_634e1985e257 class=aspNetDisabled type=button value="Open Case" name=c_SubmitCaseLookupButton_adbfe763_6470_4337_8bce_634e1985e257>

(The ****** say "on click", without a space. Not sure why it stars that part out.)
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
hmmm ... have you tried using a send key, or clicking in the search box with vba? it not perfect, but maybe you could enter something... then delete it... then enter the caseNbr ? play with it... see it will trigger it for you

Code:
Public Declare Function SetCursorPos Lib "user32" (ByVal x As Long, ByVal y As Long) As Long
Public Declare Sub mouse_event Lib "user32" (ByVal dwFlags As Long, ByVal dx As Long, ByVal dy As Long, ByVal cButtons As Long, ByVal dwExtraInfo As Long)
Public Const MOUSEEVENTF_LEFTDOWN = &H2
Public Const MOUSEEVENTF_LEFTUP = &H4
Public Const MOUSEEVENTF_RIGHTDOWN As Long = &H8
Public Const MOUSEEVENTF_RIGHTUP As Long = &H10

Public Sub ClickMouseLeft()
  SetCursorPos 80, 183 'left/right , Up/Down postion
  mouse_event MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0
  mouse_event MOUSEEVENTF_LEFTUP, 0, 0, 0, 0
  Application.Wait Now + TimeValue("00:00:01")
SendKeys ("TEST DATA"), True
End Sub
 
Upvote 0
I have not tried that (try to steer clear from send keys, but might be the only option in this scenario). Thanks!
 
Upvote 0
Have you tried clicking the button anyway?
 
Upvote 0
yes, it doesn't do anything. :/ I even tried to manually click the button, and it remains disabled until it detects typing in the search field, then it springs to life.
 
Upvote 0
I'm now playing around with trying to grab the "on click" event command from the button (which changes the java gibberish part "c_UcnEntryBox_adbfe763_6470_4337_8bce_634e1985e257" each time you log on to the page) and have the code run that event without clicking the button. I'll post an update if I'm successful.
 
Upvote 0
How did you try clicking the button in code?

Also, if the button is part of a form have you tried submitting the form?
 
Upvote 0
I tried this to click the button:

Code:
    Set itm = doc.getElementsByTagName("input")
    For Each itm In itms
        If itm.Type = "button" Then
            itm.Click
            Exit For
        End If
    Next itm

How do I submit the form?
 
Upvote 0
To submit the first form on the page.
Code:
doc.forms(0).submit
You can also use the form name, if it has one.
 
Upvote 0

Forum statistics

Threads
1,216,156
Messages
6,129,192
Members
449,492
Latest member
steveg127

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