VBA, Excel 2010, open internet explore in new tab

﹥>﹥吖頭↗ 提交于 2019-12-08 07:10:37

问题


I have searched, tried various parameters, flags switches. No luck

Here's what I'm trying to do. I have a spreadsheet that has various company names. It has VBA code that when clicked on the company name, the macro opens the financials for that company on Google finance or yahoo finance, ... but, it always open on a new window. For comparison purposes, it would be a lot more useful if all of this were on different tabs of the same window.

Is there any way to change the code so that when a company name is clicked on, that web page opens on a new tab of an already open iexplorer. I am using VBA, excel 2010, Win7


回答1:


Assuming that IE is an object variable representing an instance of InternetExplorer.Application:

Sub TestNewTabInIE()
' modified from code originally found at:
'http://www.ozgrid.com/forum/showthread.php?t=174692
Dim IE As Object

Set IE = CreateObject("InternetExplorer.Application")

With IE
    .Visible = True
    While .ReadyState <> 4 'READYSTATE_COMPLETE
        DoEvents
    Wend
    '# Navigate to one URL
    .Navigate "http://google.com"
    '# Navigate to another URL, in a new tab.
    .Navigate "Http://yahoo.com", CLng(2048)
End With
End Sub

Sometimes it is hard to find answers if you don't know what question to ask. I find the answer using this google query:

https://www.google.com/search?q=VBA+explorer+new+tab

I always make sure my query has "VBA" in it, and a few words describing what I'm trying to do. It is usually also helpful to include relevant methods or properties (e.g., "VBA explorer .Navigate new tab" might be similarly useful). I have found that the results matching these terms tend to be more precise/complete.

It was the #2 result:

http://www.ozgrid.com/forum/showthread.php?t=174692



来源:https://stackoverflow.com/questions/17386091/vba-excel-2010-open-internet-explore-in-new-tab

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!