Hi all,
I am working on a VBA script that automatically fills in a form on a website. Right now I get the following error right after it opens internet: The object invoked has disconnected from its clients.
At my homepc the macro works fine.
Script:
What are your thoughts on this why I get the error?
Thanks!
I am working on a VBA script that automatically fills in a form on a website. Right now I get the following error right after it opens internet: The object invoked has disconnected from its clients.
At my homepc the macro works fine.
Script:
Sub Automate_IE_Load_Page()
'This will load a webpage in IE
Dim i As Long
Dim URL As String
Dim IE As Object
Dim objElement As Object
Dim objCollection As Object
'Create InternetExplorer Object
Set IE = CreateObject("Internetexplorer.application")
'Set IE.Visible = True to make IE visible, or False for IE to run in the background
IE.Visible = True
'Define URL
URL = "spl.dhl.com/smcfs/console/BR2shipment.search"
'Navigate to URL
IE.Navigate URL
' Wait while IE loading...
Do While IE.readyState = 4: DoEvents: Loop
Do Until IE.readyState = 4: DoEvents: Loop <---Error is marked here by the error handler.
Set objCollection = IE.document.getElementsByTagName("input")
i = 0
While i < objCollection.Length
If objCollection(i).Name = "xml:/Shipment/@ShipmentNo" Then
' Set text for search
objCollection(i).Value = "9315"
Else
If objCollection(i).Type = "submit" And _
objCollection(i).Name = "btnSearch" Then
' "Search" button is found
Set objElement = objCollection(i)
End If
End If
i = i + 1
Wend
objElement.Click ' click button to search
'Unload IE
Set IE = Nothing
Set objElement = Nothing
Set objCollection = Nothing
End Sub
What are your thoughts on this why I get the error?
Thanks!