Question : Automatic login to website using Visual Basic 6

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

 
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
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

Answer : Automatic login to website using Visual Basic 6

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?

1:
IE.Document.getElementById("Login1_LoginButton").Click
Random Solutions  
 
programming4us programming4us