访问时坠毁,并没有错误调用此VBA:调用函数
Public IE As InternetExplorer
Private Declare Sub Sleep Lib "kernel32" (ByVal lngMilliSeconds As Long)
Dim el As Object
Public Function IEClick(Idstr As String)
Do
Set el = Nothing
On Error Resume Next
Set el = IE.Document.getElementById(Idstr)
On Error GoTo 0
DoEvents
Sleep (100)
Loop While el Is Nothing
Sleep (1000)
IE.Document.getElementById(Idstr).Click
End Function
其时,真正的循环,直到找到正确的elementid我有一个问题。当这个函数被调用像这样的时候,我在这条线上没有错误信息IEClick Str(Item)
。
For Each Item In coll
IEClick Str(Item)
p = p + 1
Next
这是完整的代码体。
Public Sub AutoExtract()
Dim ProgressBar_Extract As Object
Dim coll As Collection
Set coll = New Collection
'/////////////////controls in order///////////////
With coll
.Add "ctl00_cmdCustom"
.Add "chkAll"
.Add "ctl00_cmdContinue"
End With
Me.ProgressBar_Extract.Max = coll.Count
'////////////////////start ie//////////////////
Set IE = New InternetExplorerMedium
With IE
'.AddressBar = False
'.MenuBar = False
.Navigate ("*****")
.Visible = True
End With
'//////////////////////Start Automation///////////////////
For Each Item In coll
IEClick Str(Item)
p = p + 1
Next
MsgBox "Extract Complete"
End Sub
我把范围缩小到IEClick Str(Item)
。当调试,如果我制止它,一步下一个崩溃行。
*“没有错误信息时崩溃”*是什么意思?它锁定?或者它关闭(然后Access进程仍然运行?)? – Andre
@Andre关闭进程没有运行。 – Quint
作为第一步,我推荐一个完整的[反编译](http://stackoverflow.com/a/3268188/3820271)。 – Andre