【发布时间】:2015-07-28 19:03:05
【问题描述】:
如果用户在 MsgBox 弹出窗口中单击“是”,我试图在 Internet Explorer 输入复选框上简单地选中“是”,或者如果用户在 MsgBox 上单击“否”,则不执行任何操作。无论我尝试什么,代码似乎都没有点击我希望它点击的按钮。
我的代码如下:
strPrompt = "Please look to see if this client has a valid brokerage account available for enrollment. Would you like to enroll this client in FRT service and submit a ticket?"
strTitle = "User Input Required"
iRet = MsgBox(strPrompt, vbYesNo, strTitle)
If iRet = vbYes Then
Enrollment_Button = objIE.document.getElementsById("classActionFlagReq")
Enrollment_Button.Value = "Y"
Else
MsgBox "No"
End If
我还将包含包含“是”和“否”按钮的 HTML 源代码:
<SPAN class=radio2>
<input name="classActionFlagReq" class="radio2" type="radio" value="Y"></input>
</span>
<SPAN class=radio2>
<input name="classActionFlagReq" class="radio2" type="radio" value="N"></input>
</span>
我哪里出错了? 更新编辑代码:
iRet = MsgBox(strPrompt, vbYesNo, strTitle)
If iRet = vbYes Then
Set Enrollment_Button = objIE.document.getElementById("classActionFlagReq")
Enrollment_Button.Checked = True
Else
MsgBox "No"
End If
【问题讨论】:
标签: html vba excel internet-explorer input