We help IT Professionals succeed at work.

Automatic login to website using Visual Basic 6

matthew89
matthew89 used Ask the Experts™
on
I'm having problems with this code. Ive managed to get the code to automatically enter the username and password to my media server. The problem i'm having is trying to get Visual Basic 6 to automaticaly push the sign in/login button.

I get Run time Error "438"
object doesn't support this property or method.

It seems to be pointing towards the Login1_LoginButton section line 22.

Anyone have any other methods please.

Thanks,
matt

 
Public Sub LoginMediaCentre(ByVal szUserName As String, ByVal szPassword As String)
  
  Dim IE As Object
  
  Set IE = CreateObject("InternetExplorer.Application")
  
  IE.Visible = True
  
  ' Navigate to Media Server .
  IE.Navigate "http://mediaserver:49490/login.aspx?ReturnUrl=%2fdefault.aspx"
  
  ' Wait for the page to load.
  Do While IE.Busy Or IE.ReadyState <> 4
    DoEvents
  Loop
 
  ' Enter username
  IE.Document.getElementById("Login1_UserName").Value = szUserName
  ' Enter password
  IE.Document.getElementById("Login1_Password").Value = szPassword
  ' Submit the sign in.
  IE.Document.getElementById("Login1_LoginButton").Submit
  
  
  ' Destroy object.
  Set IE = Nothing

End Sub

Private Sub Form_Load()
LoginMediaCentre "mcuser", "password"
Unload Me
End Sub

Open in new window

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2010
Commented:
The website link doesn't work for me but you can try using the .Click() method instead of .Submit() to see if that works.  You can verify that (Login1_LoginButton) exists and that it's not any typo error?
 

IE.Document.getElementById("Login1_LoginButton").Click

Open in new window

Author

Commented:
Thank you, egl1044

Worked changing .Submit to .Click