VBA interacts with radio buttons on a web page

EDIT: a few months later I tried again to use the same syntax that I tried for the first time (see below). For some reason this worked! Perhaps something other than my syntax was causing inefficiencies ... END EDIT

I’ve been looking for forums for a couple of hours trying to find a solution to this problem, but none of the things I tried work.

I use VBA to automate the SurveyMonkey survey creation process. So far, I could:

  • Log in to my account
  • Click multiple hyperlinks to create a new response collector,
  • What is the collector
  • Go to the collector settings,
  • And select three of the four switches to change the collector settings.

The problem is not that I cannot select the radio buttons; my code selects the first three buttons just fine. What puzzles me is that the fourth button does not change! I use the same process for each button, so I cannot understand why the last button will not be selected.

Here is the section of my code:

objIE.Document.getElementById("rdlResponseType_1").Click    'Allow multiple responses = Yes
objIE.Document.getElementById("rdlResponseEdit_1").Click    'Allow Responses to be Edited = Yes
objIE.Document.getElementById("rdlThankyou_1").Click        'Display a "Thank You" page? = Yes
objIE.Document.getElementById("rdlCompleteOpt_1").Click     'Survey Completion = Close Window

This is the HTML for the switches:

<table border="0" cellpadding="0" cellspacing="0" style="width: 100%;">
                        <tr id="CompleteOptDesc">
            <td style="">&nbsp;</td>
            <td>After the respondent leaves the survey:</td>
        </tr>

                        <tr id="CompleteOptItems">
            <td style="">&nbsp;</td>
            <td align="left" nowrap="nowrap" valign="top">
                                <table id="rdlCompleteOpt" class="Clean radioList" OnClick="radioToggle('rdlCompleteOpt', '0', 'panLink');" name="rdlCompleteOpt" border="0" style="white-space: nowrap">
                <tr>
                    <td><span style="white-space: nowrap"><input id="rdlCompleteOpt_0" type="radio" name="rdlCompleteOpt" value="0" checked="checked" /><label for="rdlCompleteOpt_0"><b>Redirect</b> to your own webpage.</label></span></td>
                </tr><tr>
                    <td><input id="rdlCompleteOpt_1" type="radio" name="rdlCompleteOpt" value="2" /><label for="rdlCompleteOpt_1"><b>Close Window</b></label></td>
                </tr>
            </table>

Here is the code for the radio switching section:

<td width="65%" valign="top">
                                <div id="panLink" style="DISPLAY:inline">

                                    <div class="URLinfo">

                                            <b>Enter a URL</b> to jump to upon leaving the survey:<br />
                                            <div title="REQUIRED: Enter URL (255 character max)" style="padding:4px 0 2px 0;">
                                                <input name="txtWebLink" type="text" value="http://www.surveymonkey.com/" maxlength="255" size="40" id="txtWebLink" class="RQR opaque" />
                                            </div>
                                            <span class="tip">Example: <u>http://www.mysite.com/home.html</u></span>
                                    </div>

            </div>
                            </td>

Any suggestions would be greatly appreciated!

+5
source share
1 answer

There are several things to consider:

  • When do you call this code? OnNavigate or DocumentComplete? Perhaps the object does not exist yet. You can check if this works with a breakpoint and add hours for expressions

    objIE.Document.getElementById("rdlCompleteOpt_1")
    

    Use OnDocumentComplete to provide HTML components

  • , , , .

    Call objIE.Document.getElementById("rdlCompleteOpt_1").Click()
    

    , , .

  • , "". , JavaScript, JavaScript IE (F12)?

    , , . , , , VBA . . # 2, , , .

    , HTML? , ?

    objIE.Document.getElementById("rdlCompleteOpt_1").Click     'Survey Completion = Close Window
    objIE.Document.getElementById("rdlResponseType_1").Click    'Allow multiple responses = Yes
    objIE.Document.getElementById("rdlResponseEdit_1").Click    'Allow Responses to be Edited = Yes
    objIE.Document.getElementById("rdlThankyou_1").Click        'Display a "Thank You" page? = Yes
    

    "" ?

  • , , HTML , .

            </tr>
    
        </table>
       <!-- missing -->
       </td>
      </tr>
    </table>
    
  • , , . surveillanceymonkey, API SurveyMonkey , API .

    • , .
    • "" , ( , API)
+2

All Articles