+ Reply to Thread
Results 1 to 4 of 4

Submit IE Form with same Name (different values)

Hybrid View

  1. #1
    Registered User
    Join Date
    04-08-2010
    Location
    Northeast
    MS-Off Ver
    Excel 2003
    Posts
    10

    Submit IE Form with same Name (different values)

    Hello all,

    I've searched all over the net and was unsuccessfull at clicking a button that has the same name as another button in the IE Document form, just different values. Here's the source code of the website:

    <form name="reportForm" method="post" action="/okrta/portfolio/krta/map/standard.do">
          <TABLE border="0" cellspacing="3" cellpadding="3">
          
                <td class="Header" align="left">&nbsp;</td>
                <td colspan="2"><br>Choose the cooperative below:<br>
                   <select name="orgId"><option value="AK002">AK002 - Matanuska Electric Association, Inc.</option>
    <option value="AK003">AK003 - Kodiak Electric Association, Inc.</option>
    <option value="AK005">AK005 - Homer Electric Association, Inc.</option>
    <option value="AK006">AK006 - Golden Valley Electric Association, Inc.</option>
    <option value="AK007">AK007 - Alaska Electric Light &amp; Power Company of Juneau</option>
    <option value="AK008">AK008 - Chugach Electric Association, Inc.</option>
                <TABLE border="0" cellspacing="3" cellpadding="3">
                   <tr align="left" valign="top" class="NormalText">
                      <td><input type="submit" name="action" value="View" class="button"></td>
                      <td><img src="/images/okrta-app/spacer.gif" height="1" width="1"></td>
                      <td><img src="/images/okrta-app/pdf.gif"></td>
                      <td><img src="/images/okrta-app/spacer.gif" height="1" width="1"></td>
                      <td>Viewing the KRTA Report as a PDF document is ideal for printing.  You will also be able to download and save the PDF document.  However, the PDF document is not editable.  If you want to be able to reformat or perform additional calculations with the data, you should view the report as an Excel spreadsheet.</td>
                   </tr>
                   <tr align="left" valign="top" class="NormalText">
                      <td><input type="submit" name="action" value="Download"class="button"></td>
                      <td><img src="/images/okrta-app/spacer.gif" height="1" width="1"></td>
                      <td><img src="/images/okrta-app/xls.gif"></td>
                      <td><img src="/images/okrta-app/spacer.gif" height="1" width="1"></td>
                      <td>Viewing the KRTA Report as an Excel Spreadsheet will allow you to reformat or perform additional calculations with the data.  You will also be able to print, download and save this report.  It may take a few minutes to generate and display the Excel spreadsheet on your screen.  You will either get a file save dialog box or the spreadsheet will just open in your web browser. In the latter case, just choose "Save As" from the file menu. Choose any name for the file you like, as long as it ends in .xls (for Excel).</td>
                   </tr>
                </TABLE>
    How does one submit that specific button (the Download button) in that form? Thank you so much!

    ie.Document.getElementById("action").Value("Download").submit doesn't work and I can't reference it
    ie.Document.getElementById("action").Value = "Download" just names the other button "Download" and errors out when submitted.

    Maybe I need an "onmousover" type event? Thanks in advance for any help. The attachment shows what the website looks like.
    Attached Images Attached Images

  2. #2
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Submit IE Form with same Name (different values)

    Maybe:

    ie.Document.getElementByName("action").submit



  3. #3
    Registered User
    Join Date
    04-08-2010
    Location
    Northeast
    MS-Off Ver
    Excel 2003
    Posts
    10

    Re: Submit IE Form with same Name (different values)

    Quote Originally Posted by snb View Post
    Maybe:

    ie.Document.getElementByName("action").submit
    Thanks for the quick reply. The reason this doesn't work is because there are two buttons with the name "action" on the same form (highlighted in red). The value= "Download" is the button I want to click

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Submit IE Form with same Name (different values)

    Hello BByrd,

    This macro can be run after you have started Internet Explorer. It will find the form named "reportForm" , locate the input button "Download" and then click the button for you. The macro will inform you if either the form or button can not be found.
    ' Thread:  http://www.excelforum.com/excel-programming/808002-submit-ie-form-with-same-name-different-values.html
    ' Poster:  BByrd
    ' Written: January 04, 2012
    ' Author:  Leith Ross
    
    Sub ClickDownloadButton()
    
        Dim btn As Object
        Dim frm As Object
        Dim Found As Boolean
        Dim ieApp As Object
        Dim ieDoc As Object
        Dim ieForms As Object
        Dim ieBtns As Object
        Dim Shell As Object
        
            Set Shell = CreateObject("Shell.Application")
            Set ieApp = Shell.Windows(0)
            Set ieDoc = ieApp.Document
            
                Set ieForms = ieDoc.getElementsByTagName("form")
            
                For Each frm In ieForms
                    If frm.Name = "reportForm" Then
                       Found = True: Exit For
                    End If
                Next frm
                
                If Not Found Then
                   MsgBox "The Form ""reportForm"" was not found in this document.", vbCritical
                   Exit Sub
                End If
                
                    Set ieBtns = frm.getElementsByTagName("input")
                    
                    For Each btn In ieBtns
                        If btn.Value = "Download" Then
                           btn.Click: Exit Sub
                        End If
                    Next btn
                    
                MsgBox "The Input Button ""Download"" was found on this Form.", vbCritical
                
    End Sub
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1