获取所有打开的chrome选项卡路径

时间:2019-05-05 14:09:01

标签: excel vba google-chrome

你好,任何人都可以提供此代码

我发现了一些用于检索Internet Explorer打开的URL的代码,并且希望访问CHROME APPLICATION来执行相同的操作

获取所有打开的镶边选项卡路径

Sub List_IE_Windows_URL()  'Dim a(), w
  Dim url As String
  Dim i As Long
  With CreateObject("Shell.Application")
    ReDim a(1 To .Windows.Count, 1 To 1)
    For Each w In .Windows
           If TypeName(w.Document) = "HTMLDocument" Then
        url = Replace(w.LocationURL, "%20", " ")
        i = i + 1
        a(i, 1) = url
        Debug.Print i, url
      End If
    Next
  End With
  If i Then Range("A1").Resize(i).Value = a()
End Sub

Sub getALLBrowsers()
    Dim mainWorkBook As Workbook
    i = 2

    Set objShell = CreateObject("Shell.Application")
    Set objAllWindows = objShell.Windows
    Set mainWorkBook = ActiveWorkbook

    For Each ow In objAllWindows
        If (InStr(1, ow, "Internet Explorer", vbTextCompare)) Then
            mainWorkBook.Sheets("browsers").Range("A" & i) = ow
            mainWorkBook.Sheets("browsers").Range("B" & i) = ow.Hwnd
            mainWorkBook.Sheets("browsers").Range("C" & i) = ow.Document.Title
            mainWorkBook.Sheets("browsers").Range("D" & i) = ow.LocationURL
            i = i + 1
            'MsgBox ow.Hwnd & "  " & ow & "   " & ow.locationURL & "  " & ow.Document.Title
        End If
    Next
End Sub

0 个答案:

没有答案