【问题标题】:Excel VBA to change dropdown menu within a formExcel VBA更改表单内的下拉菜单
【发布时间】:2016-05-24 20:11:32
【问题描述】:

我尝试了一些替代方法,但没有成功,要更改组合框,您可以在下面找到网站代码(看起来问题是组合框在表单内 - 我也无法更改输入框) :

<form action="procRelLmPorData.asp" method="post" target="ifrmGerar" id="frmGerar" name="frmGerar">
<input type="hidden" name="ordem" id="ordem" value="" />

<table style="width:100%;" cellpadding="0" cellspacing="0">
<tr>
<th class="header">Licenças Médicas por Data</th>
</tr>
</table>
<table style="border-bottom:#048282 thin solid;width:100%;">    
<tr>
<td style="width:20%;vertical-align:top;">
<table>
 <tr>
  <td>Regional: </td>
  <td>
   <select style="width:200px" name="regional" id="regional" onchange="comboFilial(this.value);comboSetor('');">
    <option value="">Selecione</option>
     <option value='67'>RJ</option>
    </select>

我已经尝试了以下代码来解决它:

假设objie = InternetExplorer.Application

第一个 - objie.Document.forms("frmGerar").getElementsByTagName("select")("regional").Value = 67

第二个 - objie.Document.forms("frmGerar").Item("regional").Value = 67

第三 - objie.Document.getElementById("regional").selectedindex= 2

你能找出问题所在吗?

编辑


我发现表单在 IFrame 中,您可以在下面找到代码:

<iframe name="ifrmCentro" id="ifrmCentro" src="mapPath.asp?codMenu=404" frameborder="0" style="border: 0px currentColor; border-image: none; width: 100%; height: 177px; display: block;"></iframe>

【问题讨论】:

  • 我认为这与 VBA 无关
  • 是的。事实上,我做到了,并将发布代码。

标签: vba excel internet-explorer-11


【解决方案1】:

我做到了。

问题在于 iFrame,我必须浏览它。

.Navigate Website & "mapPath.asp?codMenu=404"

Do While .Busy Or .ReadyState <> 4
DoEvents
Loop

之后我可以填充这些框并选择组合框:

.Document.all("datInicial").Value = Range("A6").Text
.Document.all("datFinal").Value = Range("A7").Text
.Document.all("regional").Value = 67

谢谢!

【讨论】:

    猜你喜欢
    • 2016-05-19
    • 2022-06-22
    • 1970-01-01
    • 2019-11-02
    • 1970-01-01
    • 2018-01-27
    • 2014-05-27
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多