I have an Issues when calling this
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
Its to loop true untill it finds the correct elementid. I crash with no error message on this line IEClick Str(Item)
when the Function is being called like so.
For Each Item In coll
IEClick Str(Item)
p = p + 1
Next
This is the full body of code.
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
I narrowed it down to IEClick Str(Item)
.When debugging if I put a stop on it and step to next line it crashes.