javascript - 在 VBA 中使用脚本时出错
问题描述
**Public Sub WebTest()
Dim keys As New keys, arr(), ws As Worksheet, i As Long
Dim temp1(), temp2() As String
'Set ws = ThisWorkbook.Worksheets("Sheet1") '<==Adjust to your sheet
arr = Application.Transpose(Selection) '<== Adjust to your range
With bot
.Start "Chrome"
.Get "url here"
For i = LBound(arr) To UBound(arr)
If Not IsEmpty(arr(i)) Then
If i > 1 Then
.ExecuteScript "window.open(arguments[0])", "url here"
.SwitchToNextWindow
End If
.FindElementByCss("[name=q]").SendKeys arr(i)
.SendKeys bot.keys.Enter
End If
Next
End With
End Sub**
我正在使用上面的代码从 excel 中获取值并在特定的 url 中搜索。在执行加载两个搜索并在此之后显示错误为“运行时错误 17 javascript 错误非法调用”时,我不知道代码中缺少什么或需要更改的内容。
解决方案
推荐阅读
- xcode - 如何在 SwiftUI 中显示长文本/文章?
- python - 单引号中的 Python 正则表达式版本
- python - 从文件加载时 PyQt5 UI 不显示
- html - VBA 在没有 HREF 的网页上单击链接并包含相同的类名
- json - 如何在不覆盖文件的情况下正确将此数据写入 JSON 文件?
- asp.net - 如何使用 Simple Injector 或 Microsoft.Extensions.Dependency 将视图依赖项注入 ASP.NET Web 窗体中的 Presenter (MVP)?
- javascript - 提交后仍会重定向 AJAX 调用的联系表单
- unity3d - 如何从 Animator 中检索当前正在播放的动画?
- wordpress - 如何在wordpress插件联系表7中验证当前服务器时间?
- python - 如何使用 matplotlib 绘制 0/1 的数组