Hello,
I have a main sub called 'NameandDOB'. In there I call a sub routine 'ackchecker' which opens IE, goes to a website and checks if there is an acknolwedgment warning. If there isn't, it brings me to the login page. If there is, it checks the box and brings me to the login screen. The sub routine works fine.
The probelm seems that after the 'ackchecker' sub is complete and it goes back to the main sub, it doesn't seem to remember the IE session. I want to use the same IE object that was created in the 'ackchecker' sub routine.
Any help is greatly appreciated!
I have a main sub called 'NameandDOB'. In there I call a sub routine 'ackchecker' which opens IE, goes to a website and checks if there is an acknolwedgment warning. If there isn't, it brings me to the login page. If there is, it checks the box and brings me to the login screen. The sub routine works fine.
The probelm seems that after the 'ackchecker' sub is complete and it goes back to the main sub, it doesn't seem to remember the IE session. I want to use the same IE object that was created in the 'ackchecker' sub routine.
Any help is greatly appreciated!
Code:
Public Sub nameandDOB()Dim objelement As Object
Dim c, LastRow, i, j, intIndex, intMax As Integer
Dim sht As Worksheet
Call ackchecker
With ie.Document
.all("txtUserName").Value = usertextbox.Value
.all("txtPassword").Value = passwordtextbox.Value
.all("btnSubmit").Click
End With
Code:
Public Sub ackchecker()Set ie = CreateObject("InternetExplorer.Application")
With ie
.Visible = True
.navigate "https://www.njmmis.com"
End With
On Error Resume Next
If ie.Document.GetElementByID("chkbx") Is Nothing Then
'Go to the login page and execute the rest of the procedure
ie.navigate "https://www.njmmis.com/login.aspx"
Else
'Check the box
ie.Document.all("chkbx").Checked = True
'Click the continue button
ie.Document.GetElementsByTagname("input")(1).Click
ie.navigate "https://www.njmmis.com/login.aspx"
End If
End Sub