簡體   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