fill out form using vba and chrome

余生长醉 提交于 2019-12-04 16:12:23
BenShim

You can use this Selenium wrapper to drive Chrome or Firefox (or PhantomJS). Note that it is currently in beta. Once it is installed, either add a reference to Selenium Type Library or use late binding (example below).

In my (very) limited tests, the only noticeable difference is the couple seconds it takes to load the driver.

Here is a simple example from the link above (modified to use late binding) that fills out the search field in Google and clicks the search button:

Dim selDriver As Object
Set selDriver = CreateObject("Selenium.WebDriver")

selDriver.Start "chrome", "http://www.google.com/"
selDriver.Open "http://www.google.com"
selDriver.Type "name=q", "Eiffel Tower"
selDriver.Click "name=btnG"

selDriver.stop

As of 2016, the Selenium wrapper was moved to Github instead of the above Google address. Additionally, if you're using Chrome you'll want to update the web driver for Google Chrome here.

Selenium Basic

After downloading these items you'll then need to follow the instructions above for adding the library to in your Visual Basic Editor from within Excel. Afer doing so, you should be able fill out a web form using vba and chrome as originally requested.

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