我是新来的,我正在尝试编写一个VBA Excel脚本来自动化外部网站的表单输入。该网站使用dojo,我使用的是IE11。我有办法将excel vba集成到dojo中吗?
我在使用select元素的selectedIndex属性将州的下拉框更改为我想要的状态时遇到了很多麻烦。我也尝试使用execScript来尝试使用Javascript来调用dojo函数。我能够更改输入字段(键入字段)。我在这个论坛中寻找答案,但没有任何效果。有人可以帮忙吗?
我试过的代码
IE.document.currentWindow.execScript code:="dijit.getID('state').set('value','TEXAS');" //returns 80020101 error
IE.document.currentWindow.execScript code:="dojo.eval(dijit.getID('state').set('value','TEXAS'));" //returns 80020101 error
IE.document.getElementById("state").Focus
IE.document.getElementById("state").value = "NEW YORK"
IE.document.getElementById("state").FireEvent ("onchange")
IE.document.getElementById("state").Focus
IE.document.getElementById("state").selectedIndex = 29
IE.document.getElementById("state").FireEvent ("onchange")
来自网站
<div>
<label for="state" id="state_label" class="showHints">State for withholding</label>
<div><select id="state" name="state" data-dojo-type="dijit.form.FilteringSelect"><option value="ALABAMA">Alabama</option> <option value="ALASKA">Alaska</option><option value="ARIZONA" selected="selected">Arizona</option><option value="ARKANSAS">Arkansas</option><option value="CALIFORNIA">California</option><option value="COLORADO">Colorado</option><option value="CONNECTICUT">Connecticut</option><option value="DELAWARE">Delaware</option><option value="FLORIDA">Florida</option><option value="GEORGIA">Georgia</option><option value="HAWAII">Hawaii</option><option value="IDAHO">Idaho</option><option value="ILLINOIS">Illinois</option><option value="INDIANA">Indiana</option><option value="IOWA">Iowa</option><option value="KANSAS">Kansas</option><option value="KENTUCKY">Kentucky</option><option value="LOUISIANA">Louisiana</option><option value="MAINE">Maine</option><option value="MARYLAND">Maryland</option><option value="MASSACHUSETTS">Massachusetts</option><option value="MICHIGAN">Michigan</option><option value="MINNESOTA">Minnesota</option><option value="MISSISSIPPI">Mississippi</option><option value="MISSOURI">Missouri</option><option value="MONTANA">Montana</option><option value="NEBRASKA">Nebraska</option><option value="NEVADA">Nevada</option><option value="NEW_HAMPSHIRE">New Hampshire</option><option value="NEW_JERSEY">New Jersey</option><option value="NEW_MEXICO">New Mexico</option><option value="NEW_YORK">New York</option><option value="NORTH_CAROLINA">North Carolina</option><option value="NORTH_DAKOTA">North Dakota</option><option value="OHIO">Ohio</option><option value="OKLAHOMA">Oklahoma</option><option value="ORGEON">Oregon</option><option value="PENNSYLVANIA">Pennsylvania</option><option value="RHODE_ISLAND">Rhode Island</option><option value="SOUTH_CAROLINA">South Carolina</option><option value="SOUTH_DAKOTA">South Dakota</option><option value="TENNESSEE">Tennessee</option><option value="TEXAS">Texas</option><option value="UTAH">Utah</option><option value="VERMONT">Vermont</option><option value="VIRGINIA">Virginia</option><option value="WASHINGTON">Washington</option><option value="WEST_VIRGINIA">West Virginia</option><option value="WISCONSIN">Wisconsin</option><option value="WYOMING">Wyoming</option><option value="WASHINGTON_DC">Washington DC</option><option value="PUERTO_RICO">Puerto Rico</option><option value="AMERICAN_SAMOA">American Samoa</option><option value="GUAM">Guam</option><option value="NORTHERN_MARIANA_ISLANDS">N. Mariana Islands</option><option value="US_VIRGIN_ISLANDS">US Virgin Islands</option></select></div>
答案 0 :(得分:0)
这应该有助于selectedindex的数值。对不起,应该发现,对我来说,结束了一天:)
set.Bind(SegmentControl).For("ValueChanged").To(vm => vm.SegmentControlValueChanged).CommandParameter(param);