Good Afternoon All,
I have created some code that automatically logs me into my works website, however when trying to get the VBA to enter value into one of the search boxes I always recieve error 438: Object doesn't support this propery or method.
This is my code below please can you help:
Option Explicit
Const MyUserName As String = "username"
Const MyPassword As String = "password"
Const READYSTATE_COMPLETE As Integer = 4
Dim objIE As Object
Sub LoginScript()
Dim Message, Title, Default
Dim MyValue As String
Dim currenttime As Date
Set objIE = CreateObject("InternetExplorer.Application")
If MsgBox("Do you want to search for a member?", vbYesNo, "Login") =
vbNo Then
With objIE
.Visible = True
.Silent = True
.Navigate ("https://XXXXXXXXX.com/")
Do Until .ReadyState = READYSTATE_COMPLETE
DoEvents
Loop
.Document.all.txtuserid.Value = MyUserName
.Document.all.txtpassword.Value = MyPassword
.Document.all.save_button.Click
Do Until .ReadyState = READYSTATE_COMPLETE
DoEvents
Loop
End With
Else
Message = "Please enter clients CTC number" ' Set prompt.
Title = "Member Search" ' Set title.
' Display message, title, and default value.
MyValue = InputBox(Message, Title)
With objIE
.Visible = True
.Silent = True
.Navigate ("https://XXXXXXXXX.com/")
Do Until .ReadyState = READYSTATE_COMPLETE
DoEvents
Loop
.Document.all.txtuserid.Value = MyUserName
.Document.all.txtpassword.Value = MyPassword
.Document.all.save_button.Click
Do Until .ReadyState = READYSTATE_COMPLETE
DoEvents
Loop
currenttime = Now
Do Until currenttime + TimeValue("00:00:10") <= Now
Loop
Do Until .ReadyState = READYSTATE_COMPLETE
DoEvents
Loop
.Document.getElementsById("txtClientRef").Value = MyValue <------ Errors Here
End With
End If
End Sub