VBA,Excel 2010,在新选项卡中打开Internet浏览 [英] VBA, Excel 2010, open internet explore in new tab
问题描述
我已经搜索并尝试了各种参数,标志开关.没有运气
I have searched, tried various parameters, flags switches. No luck
这就是我想要做的.我有一个包含各种公司名称的电子表格.它具有VBA代码,当单击公司名称时,宏会在Google财务或Yahoo财务上打开该公司的财务信息,但是,它始终在新窗口中打开.出于比较目的,如果所有这些都位于同一窗口的不同选项卡上,将会有用得多.
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.
有什么方法可以更改代码,以便在单击公司名称时,该网页在已经打开的iexplorer的新选项卡上打开.我正在使用VBA,Excel 2010,Win7
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
推荐答案
假定IE
是表示InternetExplorer.Application
实例的对象变量:
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
有时候,如果您不知道要问什么问题,很难找到答案.我使用以下Google查询找到了答案:
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
我始终确保查询中包含"VBA",并用几个词描述我要执行的操作.包括相关的方法或属性通常也很有帮助(例如,"VBA Explorer.Navigate 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.
这是第二名的结果:
http://www.ozgrid.com/forum/showthread.php? t = 174692
这篇关于VBA,Excel 2010,在新选项卡中打开Internet浏览的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!