mrmmickle1
Well-known Member
- Joined
- May 11, 2012
- Messages
- 2,461
I have been using this code to login quicker at my work for months and recently it has begun breaking on this line
Does anyone know what may have happened or how to fix this problem? The error I get is Compile Error Object library feature is not supported. Here is the full sub:
Rich (BB code):
Set htmlDoc = .Document
Rich (BB code):
Option Explicit
Sub Workbook_Open()
'make sure you add references to Microsoft Internet Controls (shdocvw.dll) and
'Microsoft HTML object Library.
'Code will NOT run otherwise.
Dim IE As Object
Dim objIE As SHDocVw.InternetExplorer 'microsoft internet controls (shdocvw.dll)
Dim htmlDoc As MSHTML.HTMLDocument 'Microsoft HTML Object Library
Dim htmlInput As MSHTML.HTMLInputElement
Dim htmlColl As MSHTML.IHTMLElementCollection
Set objIE = New SHDocVw.InternetExplorer
With objIE
.Navigate "https://www.paycomonline.net/v4/ee/ee-login.php" ' Main page
.Visible = 1
Do While .READYSTATE <> 4: DoEvents: Loop
Application.Wait (Now + TimeValue("0:00:02"))
'set user name and password
Set htmlDoc = .Document
Set htmlColl = htmlDoc.getElementsByTagName("INPUT")
Do While htmlDoc.READYSTATE <> "complete": DoEvents: Loop
For Each htmlInput In htmlColl
If htmlInput.Name = "username" Then
htmlInput.Value = "Value 1"
Else
If htmlInput.Name = "userpass" Then
htmlInput.Value = "Value 2"
Else
If htmlInput.Name = "userpin" Then
htmlInput.Value = "Value 3"
End If
End If
End If
Next htmlInput
'click login
Set htmlDoc = .Document
Set htmlColl = htmlDoc.getElementsByTagName("input")
Do While htmlDoc.READYSTATE <> "complete": DoEvents: Loop
For Each htmlInput In htmlColl
If Trim(htmlInput.Type) = "submit" Then
htmlInput.Click
Exit For
End If
Next htmlInput
End With
Application.Quit
End Sub