[VBA ] 控制IE問題
最近接觸VBA
到了這個版才知道原來VB系列快走入歷史了.....
真是哀傷
我想問一下
我從YT上看到教學https://www.youtube.com/watch?v=dShR33CdlY8
他連到IE的方法是
Dim IE As New SHDocVw.InternetExplorer
Dim HTMLDoc As MSHTML.HTMLDocument
Dim HTMLInput As MSHTML.IHTMLElement
Dim HTMLButtons As MSHTML.IHTMLElementCollection
Dim HTMLButton As MSHTML.IHTMLElement
IE.Visible = True
IE.navigate "wiseowl.co.uk"
Do While IE.ReadyState <> READYSTATE_COMPLETE
Loop
然後我又從另一人的網頁上
https://www.automateexcel.com/vba/automate-internet-explorer-ie-using/
看到另一種開IE的方法
'This will load a webpage in IE
Dim i As Long
Dim URL As String
Dim IE As Object
Dim objElement As Object
Dim objCollection As Object
Set IE = CreateObject("InternetExplorer.Application")
IE.Visible = True
URL = "https://www.automateexcel.com/excel/"
IE.Navigate URL
Application.StatusBar = URL & " is loading. Please wait..."
Do While IE.ReadyState = 4: DoEvents: Loop 'Do While
Do Until IE.ReadyState = 4: DoEvents: Loop 'Do Until
Application.StatusBar = URL & " Loaded"
我想問一下,這兩種方法會有什麼差別嗎
然後我也覺得有一點很奇怪
在等候IE載入時的程式碼
第1則是寫
Do While IE.ReadyState <> READYSTATE_COMPLETE
第2則卻是
Do While IE.ReadyState = 4
但是在VBA裡瀏覽物件的功能中查詢
READYSTATE_COMPLETE = 4
那上面2則的程式碼寫不就矛盾了嗎?
還是我誤會了什麼
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 111.248.12.21 (臺灣)
※ 文章網址: https://www.ptt.cc/bbs/Visual_Basic/M.1630832494.A.F92.html
→
09/06 22:52,
3年前
, 1F
09/06 22:52, 1F
→
09/06 22:53,
3年前
, 2F
09/06 22:53, 2F
→
09/06 22:54,
3年前
, 3F
09/06 22:54, 3F
→
09/06 22:54,
3年前
, 4F
09/06 22:54, 4F
→
09/06 22:56,
3年前
, 5F
09/06 22:56, 5F
推
09/07 09:46,
3年前
, 6F
09/07 09:46, 6F
推
09/07 15:05,
3年前
, 7F
09/07 15:05, 7F
→
09/07 15:05,
3年前
, 8F
09/07 15:05, 8F
→
09/07 15:06,
3年前
, 9F
09/07 15:06, 9F
→
09/07 15:13,
3年前
, 10F
09/07 15:13, 10F
→
09/26 15:15,
3年前
, 11F
09/26 15:15, 11F
Visual_Basic 近期熱門文章
PTT數位生活區 即時熱門文章