繁体   English   中英

VBA 用标签打开 IE

[英]VBA to open IE with tabs

Shell ("C:\Program Files (x86)\Internet Explorer\iexplore.exe   https://google.com")

这将在 IE 中打开一个窗口。 我用什么来打开更多“标签”而不是窗口?

如果我使用以下内容,它将打开两个窗口。 同样,我想要一个带有选项卡的窗口,而不是另一个窗口。 我用 google 搜索,只找到了使用dimloop代码。

Shell ("C:\Program Files (x86)\Internet Explorer\iexplore.exe   https://google.com")
Shell ("C:\Program Files (x86)\Internet Explorer\iexplore.exe   https://bing.com")

我刚刚了解到,如果在代码末尾添加以下内容,它将打开一个选项卡。 , 没有, "_blank" 但是,如果我想打开第 3、第 4 等,这不起作用。

这是不可能的,你正在尝试这样做。 IE 没有命令行开关,允许在一个新的标签窗口中打开多个 URL,就像你想要的那样。

尝试这个:

Const navOpenInBackgroundTab = &H1000
my_favorite_search_engines = Array("lycos.com", "askjeeves.com", "altavista.com")
Set IE_obj = CreateObject("InternetExplorer.Application")
IE_obj.Visible = True
For Each site In my_favorite_search_engines
    waitTill = Now() + TimeValue("00:00:02")
    While Now() < waitTill
        DoEvents
    Wend
    IE_obj.Navigate2 site, navOpenInBackgroundTab
Next site

您需要使用记事本将其转储到文件my_cool_script.vbs中,将其保存到桌面,然后运行它。

从这个答案中借用了wait代码: https : //stackoverflow.com/a/11252660/6689725

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM