简体   繁体   English

VBA 用标签打开 IE

[英]VBA to open IE with tabs

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

This will open a window in IE.这将在 IE 中打开一个窗口。 What do I use to open more "tabs" instead of windows?我用什么来打开更多“标签”而不是窗口?

If I use the following, it will open two windows.如果我使用以下内容,它将打开两个窗口。 Again, I want a window with tabs, not another window.同样,我想要一个带有选项卡的窗口,而不是另一个窗口。 I googled and only found code using dim or loop .我用 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")

I just learned if I add the following at the end of the code, it will open a tab.我刚刚了解到,如果在代码末尾添加以下内容,它将打开一个选项卡。 , Nothing, "_blank" However, this doesn't work if I want to open 3rd, 4th, etc. , 没有, "_blank" 但是,如果我想打开第 3、第 4 等,这不起作用。

This is not possible the way you are trying to do it.这是不可能的,你正在尝试这样做。 IE does not have a command line switch that allows multiple URL's to be opened in a new tabbed window like you want. IE 没有命令行开关,允许在一个新的标签窗口中打开多个 URL,就像你想要的那样。

Try this:尝试这个:

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

you'll need to dump it in a file my_cool_script.vbs using notepad, save it to your desktop, and run it.您需要使用记事本将其转储到文件my_cool_script.vbs中,将其保存到桌面,然后运行它。

borrowed the wait code from this answer: https://stackoverflow.com/a/11252660/6689725从这个答案中借用了wait代码: https : //stackoverflow.com/a/11252660/6689725

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

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