代码在相同的选项卡中打开两个链接 [英] code to open two links in same tab

查看:195
本文介绍了代码在相同的选项卡中打开两个链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在Google Chrome浏览器的同一个标签中打开两个链接。下面是我尝试过的代码,但我在Browser = Shell(Chromepath&-url URL1)行中收到File not found错误。打开第一个URL(一个登录页面)后,它应该导航到第二个URL在同一个标​​签。

  Sub Defects()
尺寸ExtractliveApp为Variant
尺寸浏览器变
尺寸网址为Variant
URL1 = 走/ ExtractliveApp
URL2 =https://Extract.live.com / SelfServiceExtracts
Chromepath = C:\Program文件(x86)\Google\Chrome\Application\chrome.exe
浏览器=壳牌(Chromepath&安培; -url URL1 )
Browser = Shell(Chromepath&-url URL2)
End Sub


 浏览器= Shell(Chromepath)h2_lin>解决方案

&安培; -url URL1)
浏览器=壳牌(Chromepath&安培; -url URL2)

应该是

 浏览器= Shell(Chromepath&-url& URL1)
浏览器= Shell(Chromepath&-url& URL2)

您需要一个空格 Chromepath ,否则Shell会寻找它找不到的 chrome.exe-url (因此错误) 。我还修正了URL变量的用法,因为它们需要在引号之外,以便正确引用它们。将它们留在里面会导致它们被直接处理,Chrome会尝试浏览到URL1而不是链接。


I need to open two links in same tab in Google chrome browser. Below is the code I have tried, But I'm getting "File not found" error in line Browser = Shell(Chromepath & "-url URL1"). After opening the first URL(a login page) then it should navigates to second URL in same tab.

Sub Defects()
Dim ExtractliveApp As Variant
Dim Browser As Variant
Dim URL As Variant
URL1 = "go/ExtractliveApp"
URL2 = "https://Extract.live.com/SelfServiceExtracts"
Chromepath = "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"
Browser = Shell(Chromepath & "-url URL1")
Browser = Shell(Chromepath & "-url URL2")
End Sub

解决方案

You have a typo in your code:

Browser = Shell(Chromepath & "-url URL1")
Browser = Shell(Chromepath & "-url URL2")

Should be

Browser = Shell(Chromepath & " -url " & URL1)
Browser = Shell(Chromepath & " -url " & URL2)

You need a space after the Chromepath as otherwise the Shell is looking for chrome.exe-url which it can't find (hence the error). I also fixed the use of your URL variables as they will need to be outside the quotes so that they are referenced correctly. Leaving them inside will cause them to be treated literally and Chrome will attempt to browse to URL1 rather than your link.

这篇关于代码在相同的选项卡中打开两个链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆