我知道如何使用Excel VBA和IE,但我想知道是否可以使用Google Chrome,因为我发现它比IE更快。
这是我的具体含义:
Set IE = CreateObject("InternetExplorer.Application")
我可以将其替换为启动Chrome而不是IE的内容吗?
答案 0 :(得分:3)
Google Chrome不提供像Internet Explorer那样的Visual Basic界面,因此您无法访问其中的任何属性(例如Document
)。您只需传递给可执行文件即可在特定地址启动chrome。
例如:
Dim path As String = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles)
Dim executable As String = Path.Combine(path, "Google\\Chrome\\Application\\chrome.exe")
Process.Start(executable, "http://google.com")
答案 1 :(得分:0)
有一个名为Selenium的优秀资源库,它有VBA Wrappers。这是一个非常基本的教程here,但如果您真的想要完成任何工作,最好的起点是示例电子表格hosted here。
答案 2 :(得分:0)
Sub test544()
Dim chromePath As String
chromePath = """C:\Program Files\Google\Chrome\Application\chrome.exe"""
Shell (chromePath & " -url http:google.ca")
End Sub