如何在下一个选项卡上使用VBA在Google搜索上添加价值?

问题描述:

这是代码:如何在下一个选项卡上使用VBA在Google搜索上添加价值?

Sub FillinternetForm() 

Dim ie As Object 

Set ie = CreateObject("Internetexplorer.Application") 

ie.Navigate "https://google.com" 

ie.Visible = True 

While ie.Busy 

DoEvents 'wait until IE is done loading page. 

Wend 

ie.Document.all("lst-ib").Value = "Fast Sub" 

ie.Navigate "https://google.com", CLng(2048) 

ie.Document.all("lst-ib").Value = "Fast slow Sub" 

End Sub 

第一个标签工作良好,当第二次打开它无法填补这个

+0

添加另一个'虽然ie.Busy'第二次导航到google.com后出现循环 – Lukas

+0

不起作用 您可以在vba上检查自己的代码并运行其工作吗? 如果你得到答案,所以给我这里的代码谢谢 – Raulsoul

请试试这个值指南:

Sub FillinternetForm() 

Dim ie As Object 

Set ie = CreateObject("Internetexplorer.Application") 

ie.Navigate "https://google.com" 

ie.Visible = True 

While ie.Busy 

    DoEvents 'wait until IE is done loading page. 

Wend 

ie.Document.getElementById("lst-ib").Value = "Fast Sub" 

ie.Navigate "https://google.com", CLng(2048) 

While ie.Busy 

    DoEvents 'wait until IE is done loading page. 

Wend 

With CreateObject("Shell.Application").Windows 

    Set ie = .Item(.Count - 1) 

End With 

While ie.Busy 

    DoEvents 'wait until IE is done loading page. 

Wend 

ie.Document.getElementById("lst-ib").Value = "Fast slow Sub" 
End Sub 
+0

你检查自己没有工作仍然。 – Raulsoul

+0

是的,我做了,它的工作。但我再次进行了测试,发现它有时会在第一个标签中输入第二个搜索文本。我会尽快再次调查它 – Lukas

+0

亲爱的我需要真正的迫切如果你现在这样做,我现在很高兴你 – Raulsoul