使用Excel VBA控制Web浏览器 [英] Controlling a web browser using Excel VBA
问题描述
我发现iMacros脚本版本是一个可行的解决方案,我想知道是否有其他类似的工具可用于控制浏览器和填写数据。
我也看过Selenium Client Driver,但我不知道如何在Excel VBA中使用它。
任何帮助将不胜感激。 / p>
谢谢,
您可以使用Visual Basic编辑器中的Selenium安装这里提供的工具:
http ://code.google.com/p/selenium-vba/
有一个Selenium IDE插件可以在VBA和安装中自动记录一个脚本包在Visual Basic中运行Selenium命令
以下示例启动firefox,打开第1列中的链接,将标题与第2列进行比较,并将结果过滤到第3列。
使用的数据位于一个名为MyValues范围的工作表中。
公共子TC002()
Dim selenium As New SeleniumWrapper.WebDriver,r As Range
selenium.Startfirefox,http://www.google.com
For each r In Range(MyValues)。行
selenium.open r.Cells(,1)
selenium.waitForNotTitle
r.Cells(,3)= selenium.verifyTitle(r.Cells(,2))
Next
selenium.stop
End Sub
I have been assigned the task of automating a web based task ( for a HTTPS website). The users currently are filling in the Excel sheet with the data, they now want to automate excel in such a way that it directly controls the browser and fills in the data.
I found the iMacros Scripting edition as a possible solution for doing this, I wanted to know if there are any other similar tools which can be used for controlling the browser and filling in data.
I also had a look at the Selenium Client Driver, but I am not sure on how to use it in Excel VBA.
Any help would be appreciated.
Thanks,
You can use Selenium from Visual Basic Editor by installing the tools provided here :
http://code.google.com/p/selenium-vba/
There is a Selenium IDE plugin to automatically record a script in VBA and an installation package to run Selenium command in Visual Basic Editor.
The following example starts firefox, opens links in the 1st column, compares the title with the 2nd column and past the result in the 3rd column. Used data are in a sheet, in a range named "MyValues".
Public Sub TC002()
Dim selenium As New SeleniumWrapper.WebDriver, r As Range
selenium.Start "firefox", "http://www.google.com"
For Each r In Range("MyValues").Rows
selenium.open r.Cells(, 1)
selenium.waitForNotTitle ""
r.Cells(, 3) = selenium.verifyTitle(r.Cells(, 2))
Next
selenium.stop
End Sub
这篇关于使用Excel VBA控制Web浏览器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!