最近接触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则的程式码写不就矛盾了吗?
还是我误会了什么