感谢您回答我以前的回答。我对VBScript很新,所以我需要再一点帮助。到目前为止,我已经使用了这段代码,并且可以正常运行
Private Sub CommandButton3_Click()
Set IE = CreateObject("InternetExplorer.Application")
With IE
.Visible = True
.navigate "http://rapido.connect.local/Forms/Refund-Request.aspx"
End With
Do Until IE.readyState = 4
DoEvents
Loop
'Find & Fill Out Input Box
IE.document.getElementbyid("p_lt_ctl03_pageplaceholder_p_lt_ctl00_On_lineForm_viewBiz_Agent_Name_txtText").Value = ThisWorkbook.Sheets("Berekeningsblad").Range("j8")
'Unload IE
endmacro:
Set IE = Nothing
End Sub
但是,表单以下拉列表开头。我尝试了几件事,但我担心我有点卡住了。我想在下拉列表中选择1个值。这是下拉列表的源代码:
<div id="p_lt_ctl03_pageplaceholder_p_lt_ctl00_On_lineForm_viewBiz_pnlForm" class="FormPanel" onkeypress="javascript:return WebForm_FireDefaultButton(event, 'p_lt_ctl03_pageplaceholder_p_lt_ctl00_On_lineForm_viewBiz_btnOK')">
<table class="EditingFormTable"><tr id="Shop"><td class="FieldLabel"><label id="p_lt_ctl03_pageplaceholder_p_lt_ctl00_On_lineForm_viewBiz_Shop_lb" class="EditingFormLabel" for="p_lt_ctl03_pageplaceholder_p_lt_ctl00_On_lineForm_viewBiz_Shop_dropDownList">Shop:</label></td><td class="EditingFormValueCell"><div id="p_lt_ctl03_pageplaceholder_p_lt_ctl00_On_lineForm_viewBiz_ncpshop" class="EditingFormControlNestedControl editing-form-control-nested-control">
<select name="p$lt$ctl03$pageplaceholder$p$lt$ctl00$On_lineForm$viewBiz$Shop$dropDownList" id="p_lt_ctl03_pageplaceholder_p_lt_ctl00_On_lineForm_viewBiz_Shop_dropDownList" class="DropDownField form-control">
<option selected="selected" value="aal@XX.be">AAL</option>
<option value="accounts@XX.be">ACC</option>
<option value="apt@xx.be">APT</option>
<option value="contactcenter@xx.be">AST CC </option>
<option value="gent@airstop.be">ASTGNT</option>
<option value="ATS@xx.be">ATS</option>
<option value="b2b@xx.be">B2B</option>
<option value="bra@xx.be">BRA</option>
<option value="brg@xx.be">BRG</option>
<option value="bto@xx.be">BTO</option>
<option value="bts@xx.be">BTS</option>
<option value="resa@xx.be">ECOM</option>
</select>
答案 0 :(得分:0)
要从该下拉列表中选择元素,您应该
IE.document.getElementbyid("p_lt_ctl03_pageplaceholder_p_lt_ctl00_On_lineForm_viewBiz_Shop_dropDownList").value = [somevalue]
其中[somevalue]是您要为该下拉列表设置的值。
或者(我还没试过),您可以尝试使用selectedIndex属性,如下所示
IE.document.getElementbyid("p_lt_ctl03_pageplaceholder_p_lt_ctl00_On_lineForm_viewBiz_Shop_dropDownList").selectedIndex = [Index]
其中[Index]是介于0和(项目数 - 1)之间的数字。