Using Excel VBA to select onchange value in JavaScript web -


i new vba, i've been tried many times use excel vba select value on website, doesn't work. below code use.

actually don't know how elements since has no "id" or "name" tag.

sub getfinancedata()    dim url string    url = "http://stock.finance.sina.com.cn/hkstock/finance/00001.html"    set myie = createobject("internetexplorer.application")    myie  .navigate url  .visible = true    while .busy = true or .readystate <> 4  loop  doevents    .document.parentwindow.execscript "selectdata(zero);", "javascript"    end    end sub

below html code, want change option value "zero" when open website, can check , advise vba code can use value "zero"? lot in advance!

enter image description here

	<a name="a1" id="a1"></a>    	<div class="part02">     	  <div class="sub01">         	  <div class="sub01_tt fblue">             	  <span class=" selected"><a href="#a1" target="_self">重要财务指标</a></span>                <span class=""><a href="#a2" target="_self">资产负债表</a></span>                <span class=""><a href="#a3" target="_self">现金流量表</a></span>                <span class=""><a href="#a4" target="_self">综合损益表</a></span>                <em class="rt">报表类型:<select class="fgrey" style="width:100px;" interface="getfinancestandardforjs?symbol=$symbol&financestanderd=" table="tablegetfinancestandard" onchange="selectdata(this);">                  <option value="all" >全部</option>                  <option value="zero" >年报</option>                  <option value="1" >中报</option>                  <option value="2" >一季报</option>                  <option value="3" >三季报</option>              </select></em>          </div>          <div class="sub01_cc">              	<div class="sub01_c">              	                	<table cellspacing="0" cellpadding="0" border="0"  class="tab05">                      <tbody id="tablegetfinancestandard">                       <tr>

indeed, addressing form element html name or id favorable in example, can use getelementsbytagname() method address select tags though have no name or id.

below code set select drop downs "zero". tested briefly , worked fine.

sub getfinancedata()     dim url string     url = "http://stock.finance.sina.com.cn/hkstock/finance/00001.html"      set myie = createobject("internetexplorer.application")     myie         .navigate url         .visible = true          while .busy = true or .readystate <> 4             loop         doevents          set selectitems = myie.document.getelementsbytagname("select")         each in selectitems             i.value = "zero"             i.fireevent ("onchange")         next     end end sub 

Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -