Sub SaphireLogIn(Optional ByVal dCloseTime As Date = 0)
Dim IE As Object, PW As String, sUserName As String
PW = InputBoxDK("Enter Your Password Please." & Chr(10) & Chr(10) & "Make sure all Sapphire windows are CLOSED, otherwise your password may show up on the screen for a few seconds!", "Password Please")
sUserName = Worksheets("Saphire").Range("K1").Value
Set IE = CreateObject("InternetExplorer.Application")
IE.Visible = True
IE.Navigate "https://k12.mtwp.net/Gradebook/ClassSelect.cfm"
' Check for good connection to web page loop!
Do
If IE.ReadyState = 4 Then
Exit Do
Else
DoEvents
End If
Loop
' Wait for window to open!
Application.Wait (Now + TimeValue("0:00:02"))
' Send logg-on information!
' May need additional SendKeys as needed?
' Determine by the actual key-stroks needed!
SendKeys sUserName, True
SendKeys "{TAB}", True ' Log On
SendKeys PW, True
SendKeys "{ENTER}", True
End Sub
Public WithEvents IE_Events As InternetExplorer
Private Sub IE_Events_DocumentComplete(ByVal pDisp As Object, URL As Variant)
Dim inp As Object
'\\ Let's go to DocumentComplete event
If (pDisp Is IE) Then
'\\ Url could change so take care of it
If InStr(1, URL, "https://k12.mtwp.net/Gradebook/ClassSelect", vbTextCompare) Then
With IE.document.all
Set inp = .Item("j_username")
inp.Value = sUserName 'Your ID
Set inp = .Item("j_password")
inp.Value = PW 'Your Password
Set inp = .Item("login") ' Press Log In
inp.Click
End With
End If
End If
End Sub
Dim objClass1 As Class1
'\\ Declare the Variables as Global so they can be seen by the Class Module
Public IE As Object, PW As String, sUserName As String
Sub SaphireLogIn()
sUserName = "Your ID"
PW = InputBoxDK("Enter Your Password Please." & Chr(10) & Chr(10) & "Make sure all Sapphire windows are CLOSED, otherwise your password may show up on the screen for a few seconds!", "Password Please")
' sUserName = Worksheets("Saphire").Range("K1").Value
Set IE = CreateObject("InternetExplorer.Application")
'\\***************ADD THESE LINES***************************\
'\\ Instantiate Class1 and Hook the Events '\
Set objClass1 = New Class1 '\
Set objClass1.IE_Events = IE '\
'\\ ********************************************************
IE.Visible = True
IE.navigate "https://k12.mtwp.net/Gradebook/ClassSelect.cfm"
End Sub
You need to set a reference to
Microsoft internet controls
how can i make an input box display *s when you type in it (so it can be used for passwords)
InputBox("Please Enter New Password")
thank you