【发布时间】:2020-01-22 19:04:53
【问题描述】:
我在 excel 中运行 VBA 以进行一些网络抓取,但在尝试访问 Google Chrome 时出现此错误。如何避免这种情况?我将点击调试,然后一行会突出显示...
这是弹出错误的地方
这是必须给出问题的突出显示的代码行
完整代码如下:
Private Sub time_sheet_filling()
Dim I As Long
Dim IE As Object
Dim doc As Object
Dim objElement As Object
Dim objCollection As Object
' Create InternetExplorer Object
Set IE = CreateObject("ChromeTab.ChromeFrame")
IE.Visible = True
' Send the form data To URL As POST binary request
IE.navigate "https://wistar.dispondo.net/#/login"
' Wait while IE loading...
Do While IE.Busy
Application.Wait DateAdd("s", 1, Now)
Loop
'Load the logon page
Set objCollection = IE.Document.getElementsByTagName("input")
I = 0
While I < objCollection.Length
If objCollection(I).Name = "username" Then
' Set text to enter
objCollection(I).Value = "MyUsername"
End If
If objCollection(I).Name = "password" Then
' Set text for password
objCollection(I).Value = "MyPasword"
End If
If objCollection(I).Type = "submit" And objCollection(I).Name = "btnSubmit" Then ' submit button clicking
Set objElement = objCollection(I)
End If
I = I + 1
Wend
objElement.Click ' click button to load the form
' Wait while IE re-loading...
Do While IE.Busy
Application.Wait DateAdd("s", 1, Now)
Loop
' Show IE
IE.Visible = True
Dim links, link
Dim n, j
Set links = IE.Document.getElementById("dgTime").getElementsByTagName("a")
n = links.Length
For j = 0 To n - 1 Step 2
links(j).Click
'I have some operations to be done will post another question for this
Next
End Sub
【问题讨论】:
-
提前感谢您的帮助!!
-
图像中的代码 文本中的代码!
Debug.print Chromepath & Sheets...an 在chrome.exe"之后看到缺少的空白(除非单元格中有一个(令人惊讶的)起始空白)。
标签: excel vba google-chrome runtime-error