2012-10-26 116 views
3

我正在编写VBS代码来打开Internet Explorer并转到www.google.com然而,当我运行该程序时,它会打开并导航到www.yahoo.com,但Internet Explorer不是前窗。谁能帮我这个?有没有我可以用来将Internet Explorer带到前台的代码?谢谢你们!这里是我的代码:将VBS脚本带到前台

Option Explicit 
Dim ie 


Set ie = CreateObject("InternetExplorer.Application") 

ie.Navigate("wwww.yahoo.com") 

最后一个问题 - 是否有一个代码,我可以用它来点击一个特定的按钮 - 特别是一个,我不能按“标签”去?

谢谢大家!

回答

2

试试这个:

Set ie = CreateObject("InternetExplorer.Application") 
ie.Navigate "http://www.yahoo.com/" 
Do While ie.Busy : WScript.Sleep 100 : Loop 
ie.Visible = True 
CreateObject("WScript.Shell").AppActivate ie.document.title 
+0

没有为我工作。它激活了应用程序,但没有出现。 :( –

0

此作品在我的电脑上它打开IE浏览器并加载www.google.com:

Dim oShell 
Set oShell = CreateObject("WScript.Shell") 
oShell.Run ("iexplore www.google.com") 

至于你的最后一个问题......也许,但你需要更具体,也许应该问在另一个问题。

2

我发现后调用使用AppActivate方法将Visible属性设置为True 作品@丹尼尔 - 厨师。

因此,简单地交换@ ansgar-wiechers示例中的最后2行可以产生所需的结果。

Set ie = CreateObject("InternetExplorer.Application") 
ie.Navigate "http://www.yahoo.com/" 
Do While ie.Busy : WScript.Sleep 100 : Loop 
CreateObject("WScript.Shell").AppActivate ie.document.title 
ie.Visible = True