VBA在TOR中打开链接的步骤(每个链接都在一个新选项卡中)



你能告诉我如何在TOR(Firefox(中打开一系列链接吗?

例如,我的代码处理一个实例(Excel中一个单元格的一个链接(,它会在TOR中打开它,但如果我选择多个单元格,它会打开一个,然后尝试打开TOR的一个新实例来打开另一个(我不能同时打开两个(。

Sub Open_Tor()
'open hyperlink in tor
Dim tor As String
'tor = "C:Program Files (x86)GoogleChromeApplicationchrome.exe"
tor = "C:UsersLenovoDesktopTor BrowserBrowserfirefox.exe"
Dim hl As Hyperlink
On Error Resume Next
For Each hl In Selection.Hyperlinks
Shell (tor & " -url-newtab " & hl.Address)
Next hl
End Sub

如果你没有TOR,你可以简单地更改Chrome的路径来测试它(Chrome会很好地打开一个又一个链接,每个链接都在一个单独的选项卡中(。

感谢

PS。我无法使用Chrome,因为我每天可以在特定服务器上执行的计算数量有限,因此使用TOR(不断更改IP(。

使用以下两个代码(粘贴在两个独立的模块中(。如果需要,在其中一张工作表上添加一个按钮(用于触发代码(,并将其指向EventMacro代码。请记住根据机器的速度/规格调整alertTimeApplication.Wait值。

Sub EventMacro()
alertTime = Now + TimeValue("00:00:08")
OpenInAnotherBrowser Sheet2.Cells(2, 2).Value 'provide a link in this location on a specific sheet (in my case Sheet2)
Application.OnTime alertTime, "EventMacro"
End Sub

现在,多亏了这段代码,您将获得一个打开/关闭Tor浏览器的循环,其中有一个位于Sheet2.Cells(2, 2)!:D

Sub OpenInAnotherBrowser(url As String)
Dim firefoxPath As String
Dim wshell As Object
Dim oExec As Object
Set wshell = CreateObject("Wscript.Shell")

firefoxPath = "C:UsersT14sDesktopTor BrowserBrowserfirefox.exe" 'provide path to Tor folder where firefox.exe is based

If Dir(firefoxPath) = "" Then pathFireFox = "C:UsersT14sDesktopTor BrowserBrowserfirefox.exe" 'provide path to Tor folder where firefox.exe is based
Set oExec = wshell.Exec(firefoxPath & " " & url)
Application.Wait (Now + TimeValue("0:00:05")) 'adjust based on your machine's specs

oExec.Terminate
Set wshell = Nothing
Set oExec = Nothing
Application.Wait (Now + TimeValue("0:00:03")) 'adjust based on your machine's specs
Application.SendKeys "^+Q" 'quit Tor
End Sub