[問題] IE自動關閉Alert?
軟體:
Excel
版本:
2016
-----
大家好,因為有數個網頁上有固定動作要常做,
所以想寫個VBA來自動處理.
不過在一些網頁處理中會跳出Alret或confirm視窗,
例如網頁是如下寫法:
javascript:
function print()
{alert("請設定橫式列印");window.print();}
我可以用以下寫法關掉alert再sendkeys列印:
VBA:
1. temp = "function print() {window.print();}"
2. ie.document.parentWindow.execScript temp
3.
4. ie.documentgetElementsByID("print").FireEvent ("Onclick")
5.
6. SendKeys "%r", True
可是有些網頁Alert在原始檔找不到,所以無法用以上方式關閉,造成VBA無法繼續.
例如上面的javascript如果我沒有去改內容,
就會造成alert發生時,因為還沒關掉,
所以下一句"window.print()"就還沒執行,
等於VBA的第四行FireEvent還沒執行完,
即便下面再加Sendkeys也無法點掉alert,
VBA的執行就停在第四行...
請問有高手有解嗎?謝謝~
網路上有找到以下資訊,但無法執行...
Set IE.document.alert = Nothing
Set IE.document.confirm = Nothing
Set IE.document.showModalDialog = Nothing
Set IE.document.Open = Nothing
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 61.63.122.208
※ 文章網址: https://www.ptt.cc/bbs/Office/M.1467468912.A.E80.html
→
07/03 09:02, , 1F
07/03 09:02, 1F
→
07/03 09:05, , 2F
07/03 09:05, 2F
推
07/03 09:08, , 3F
07/03 09:08, 3F
→
07/03 09:09, , 4F
07/03 09:09, 4F
→
07/03 09:12, , 5F
07/03 09:12, 5F
→
07/03 09:13, , 6F
07/03 09:13, 6F
→
07/03 09:16, , 7F
07/03 09:16, 7F
→
07/03 10:34, , 8F
07/03 10:34, 8F
→
07/03 10:35, , 9F
07/03 10:35, 9F
→
07/03 10:38, , 10F
07/03 10:38, 10F
→
07/03 10:41, , 11F
07/03 10:41, 11F
→
07/03 11:28, , 12F
07/03 11:28, 12F
→
07/03 11:32, , 13F
07/03 11:32, 13F
→
07/03 11:43, , 14F
07/03 11:43, 14F
討論串 (同標題文章)
Office 近期熱門文章
PTT數位生活區 即時熱門文章
-3
16