下述答案来自一个非计算机专业的VB爱好者,算是给CSDN的见面礼。
Public Function IsHPOpen(ByVal HP As String) As Boolean
IsHPOpen = False
Dim sWind As ShellWindows
Dim IE As InternetExplorer
Set sWind = New ShellWindows
TT = Now()
LINE1: Do While DateAdd("S", 20, TT) > Now() '等待20秒
For Each IE In sWind
If InStr(IE.LocationURL, HP) <> 0 Then
N = IE.Document.Frames.Length - 1
If N > -1 Then
For I = 0 To N
If UCase(IE.Document.Frames(I).Document.ReadyState) <> "COMPLETE" Then
GoTo LINE1
End If
If I = N And UCase(IE.Document.Frames(I).Document.ReadyState) = "COMPLETE" Then
GoTo LINE2
End If
Next
End If
LINE2: M = IE.Document.All.Length - 1
If M > -1 Then
If UCase(IE.Document.ReadyState) = "COMPLETE" Then
IsHPOpen = True
Exit Function
End If
End If
End If
Next
Loop
End Function