VBA to submit web form with lots of submit buttons all named ... submit...

slike

New Member
Joined
Mar 23, 2014
Messages
2
Hello all. I am looking at a web form with lots of submit buttons, all of them named "submit", and they are all in the same form. I know the correct one that should be submitted, but I do not know why I am unable to successfully submit the page. Here's the page:

General Query Criteria

So, I have populated the form fields appropriately, and now I am ready to submit the form.

My code clicks the button, submitting the value "Submit". The capital letter "S" seems to be important, but I am unable to determine what is going on.

I've tried the usual suspects --

getElementsByName
getElementsByTagName
getElementsByID

etc.

Can anybody help?
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
Sorry about that.

Here's my code:

Code:
 Sub RoundedRectangle1_Click()
    
    Dim x As Integer
    Dim F As Integer
    Dim MyMonth As String
    
    F = 1
    
    ' Set numrows = number of rows of data.
    'NumRows = Range("A2", Range("A2").End(xlDown)).Rows.Count
    NumRows = 22
    ' Select cell a1.
    Range("C2").Select
    ' Establish "For" loop to loop "numrows" number of times.
    
    'For x = 1 To NumRows
    For x = 1 To 1
        
        F = F + 2
        
        'Download Texas Railroad Commission Oil & Gas Data (TRRC Oil & Gas)
        
        Dim ie As InternetExplorer
        Set ie = New InternetExplorer
        'Set ie = CreateObject("InternetExplorer.Application")
        ie.Navigate "http://webapps.rrc.state.tx.us/PDQ/generalReportAction.do"
    
        While ie.Busy
        Wend
    
        'Radio button: Select the initial view (0=Lease, 1=Operator, 2=FIELD, 3=District, 4=County)
        Set ieRadio = ie.Document.all
        'ieRadio.Item("viewType")(2).Checked = True
        ieRadio.Item("viewType")(Worksheets("Launch").Range("F6").Value).Checked = True
        
        'Select the Start Month
        MyMonth = Worksheets("Launch").Range("D9").Value
  
            Select Case MyMonth
                Case "Jan"
                    MyMonth = "01"
                
                Case "Feb"
                    MyMonth = "02"
                
                Case "Mar"
                    MyMonth = "03"
                
                Case "Apr"
                    MyMonth = "04"
                    
                Case "May"
                    MyMonth = "05"
                
                Case "Jun"
                    MyMonth = "06"
                    
                Case "Jul"
                    MyMonth = "07"
                    
                Case "Aug"
                    MyMonth = "08"
                
                Case "Sep"
                    MyMonth = "09"
                    
                Case "Oct"
                    MyMonth = "10"
                    
                Case "Nov"
                    MyMonth = "11"
            
                Case "Dec"
                    MyMonth = "12"
            
            End Select
        
            ie.Document.getElementsByName("startMonth").Item.Value = MyMonth
        
        'Select the Start Year (as yyyy format)
        ie.Document.getElementsByName("startYear").Item.Value = Worksheets("Launch").Range("E9").Value
        
        'Select the End Month
        MyMonth = Worksheets("Launch").Range("D10").Value
  
            Select Case MyMonth
                Case "Jan"
                    MyMonth = "01"
                
                Case "Feb"
                    MyMonth = "02"
                
                Case "Mar"
                    MyMonth = "03"
                
                Case "Apr"
                    MyMonth = "04"
                    
                Case "May"
                    MyMonth = "05"
                
                Case "Jun"
                    MyMonth = "06"
                    
                Case "Jul"
                    MyMonth = "07"
                    
                Case "Aug"
                    MyMonth = "08"
                
                Case "Sep"
                    MyMonth = "09"
                    
                Case "Oct"
                    MyMonth = "10"
                    
                Case "Nov"
                    MyMonth = "11"
            
                Case "Dec"
                    MyMonth = "12"
            
            End Select
        
            ie.Document.getElementsByName("endMonth").Item.Value = MyMonth
        
        'Select the End Year (as yyyy format)
        ie.Document.getElementsByName("endYear").Item.Value = Worksheets("Launch").Range("E10").Value
        
        'Radio Button: Choose the Well Type (0=Both; 1=Oil; 2=Gas)
        Set ieRadio = ie.Document.all
        ieRadio.Item("wellType")(Worksheets("Launch").Range("F12").Value).Checked = True
        
        'Input the Field Name; the page requires two fields, the first one hidden. Set them both here.
        ie.Document.getElementsByName("fieldNameData").Item.Value = Worksheets("Active Eagle Ford fields").Range("B" & F).Value
        ie.Document.getElementsByName("fieldRegion").Item.Value = Worksheets("Active Eagle Ford fields").Range("C" & F).Value
    
        ie.Document.getElementsByName("submit").Item.Value = "Submit"
        ie.Document.getElementsByName("submit").Item.Click
        
        ie.Visible = True
        ' Selects cell down 1 row from active cell.
        ActiveCell.Offset(1, 0).Select
        
    Next
    
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,325
Members
452,635
Latest member
laura12345

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