iT邦幫忙

0

VBA IE 進入後 選項點選

使用VBA進入(透過帳號,密碼)網頁後,左邊有視窗選項,要先點選第一層後,接著會出現5個選項,總共要點二次才帶入日期輸入,此網頁是frameset>frame>架構? 如下:

< frameset >
< frame scr="menu.jsp" name="left" scrolling="auto" noresize>*
< li clas"closed collapsable">
< div class="hitarea closed-hiterarea"> </ div>
< li/>

dim c as object
set c=ie.document.contentwindow.document("left").
getElementsByClassName("hitarea closed-hiterarea")(0)
c.click

第二層選項則為: herf javaScrpipt

< a herf="javascripting;submitForm('modules/mm/fx/fx_query')"class>abcdef < /a>

dim b , a as variant 

set b=ie.document.contentwindow.document("left").getElementsBytagename("a")
for each a in b
if a.innertext="abcdef" then
a.click

點選二層後, 要輸入日期

< input id="start-date" name="start-date"

ie.document.contentwindow.document("left").doc.getElementById("start-date").value="2019/11/29"

想請教我的程式碼那裡有問題,苦惱~,感謝各位的幫忙

看更多先前的討論...收起先前的討論...
ccutmis iT邦高手 2 級 ‧ 2019-11-29 11:28:30 檢舉
建議您改用Python(最好)或是autoit(不太好 但能做跟VBA一樣的事)
用VBA處理這種事情是事倍功半還不一定搞得好。
那些是你的程式碼?
喵仔 iT邦新手 5 級 ‧ 2019-11-29 16:32:15 檢舉
對。但都無法成功...
喵仔 iT邦新手 5 級 ‧ 2019-11-30 00:46:27 檢舉
我也很想,但有時公司無法安裝軟體或要特別申請。
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

1 個回答

2
paicheng0111
iT邦大師 5 級 ‧ 2019-11-29 16:20:56

請再試試看

dim c as object
set c = ie.document.getElementsByClassName("hitarea closed-hiterarea")(0)
c.click

dim a, b
set b = ie.document.getElementsBytagename("a")
for each a in b
    if a.innertext="abcdef" then
        a.click
        exit for
    enf if
next a

IE.Document.getElementById("start-date").value="2019/11/29"
喵仔 iT邦新手 5 級 ‧ 2019-11-29 18:05:07 檢舉

謝謝pacheng0111回覆。
第一和第二段都出現Run-time error
Object doesnt support this property or method
(似乎抓不到或判斷不出frame)

第三段則是出現Run-time- error(424)

感覺就是frameset and frame那段出了問題???

我調整過請再試試看

喵仔 iT邦新手 5 級 ‧ 2019-11-29 18:55:22 檢舉

第一段c=nothing
第二段 b=object /a=empty

想特別提出來的是=frame裡面的 name="left"
D=ie.document.getelementsbyname("left")
這裡的D__[objectHTMLFrameElement]

我要發表回答

立即登入回答