简体   繁体   中英

Excel VBA to change dropdown menu within a form

I tried some alternatives, but with no success, to change the combobox you can find the website code below (It looks that the problem is that the combobox is inside a form - I can't change an input box as well):

<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>

I've tried the codes below to solve it:

Assuming that objie = InternetExplorer.Application

1st - objie.Document.forms("frmGerar").getElementsByTagName("select")("regional").Value = 67

2nd - objie.Document.forms("frmGerar").Item("regional").Value = 67

3rd - objie.Document.getElementById("regional").selectedindex= 2

Can you figure what's the problem?

EDIT


I've found that the form is inside an IFrame, you can find the code below:

<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>

I made it.

The problem was the iFrame, which I had to navigate through.

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

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

After that I could fill the boxes and select combobox:

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

Thanks!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM