Getting error while using a script in VBA

若如初见. 提交于 2020-05-17 06:49:05

问题


**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**

I'm using the above code to fetch values from excel and search in a particular url. While executing its loading two searches and after that its showing an error as "run-time error 17 javascript error illegal invocation" I don't know what I'm missing in the code or which I need to alter.

来源:https://stackoverflow.com/questions/61640111/getting-error-while-using-a-script-in-vba

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