[爆卦]Excel 2016 自動關閉是什麼?優點缺點精華區懶人包

為什麼這篇Excel 2016 自動關閉鄉民發文收入到精華區:因為在Excel 2016 自動關閉這個討論話題中,有許多相關的文章在討論,這篇最有參考價值!作者o707o7 (往前走~)看板Office標題[問題] IE自動關閉Alert?時間Sat Ju...


軟體:
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
Linkey: 用Sendkey不是好方法,送出的當下無法確定操作的目標 07/03 09:02
Linkey: 如果網頁有異常或回應較慢,用Sendkey也不會發現 07/03 09:05
Linkey: alert看不到的部分可以用瀏覽器的開發者工具去檢視 07/03 09:08
Linkey: 可以的話想申一下網址 07/03 09:09
Linkey: 最近也學用VBA操作.Net的網站,遇到Javascript的問題 07/03 09:12
Linkey: 都用繞過的方式,或者用 WinHttp 直接 post data 取資料 07/03 09:13
Linkey: 目前遇到showModalDialog非BOM無法存操作DOM內容 07/03 09:16
o707o7: 其實網頁是公司內部的網頁,所以網址想貼也不能貼... 07/03 10:34
o707o7: 同意SENDKEYS真的不是很方法,但只想到這個...只能加WAIT.. 07/03 10:35
o707o7: temp= "window.alert = function() { return true; }" 07/03 10:38
o707o7: 剛剛看到的,不知道有沒有效果... 07/03 10:41
Linkey: 因為ShowModalDialog卡關,開始從 Web Automation 找資料 07/03 11:28
Linkey: javascript injection等,但程度不好看得好累... 07/03 11:43

你可能也想看看

搜尋相關網站