//有多个网页被打开,如何确定“活动”网页的URL地址?

解决方案 »

  1.   

    '引用Microsoft Internet Controls
    Private Declare Function GetForegroundWindow Lib "user32" () As Long
    Dim IEwin As ShellWindows
    Dim strURL As String
    Private Sub Form_Load()
    Set IEwin = New ShellWindows
    Timer1.Enabled = True
    Timer1.Interval = 100
    End SubPrivate Sub Timer1_Timer()
    Dim IE As InternetExplorerFor Each IE In IEwin
      If IE.hWnd = GetForegroundWindow() Then
        If IE.LocationURL <> strURL Then
           Debug.Print IE.LocationURL
           strURL = IE.LocationURL
        End If
      End If
    Next
    End Sub