[RESOLVED] Auto Login Issue
Hello I'm looking forward to register to vbforums.com as Auto Login.
Code1 work fine but after I register as Auto Login Error Msg occured " Object variable or with block variable not set " and highlight on code line below. Any help would be appreciate. Thank you All. your replay appreciate in advance.
Code:
brwWebBrowser.Document.All("vb_login_username").Value = "brss"
Code:
Code1
Private Sub Form_Load()
Me.Show: DoEvents
brwWebBrowser.Navigate "http://www.vbforums.com/login.php?"
DoEvents
While brwWebBrowser.Busy = True
DoEvents
Wend
brwWebBrowser.Document.All("vb_login_username").Value = "brss"
brwWebBrowser.Document.All("vb_login_password").Value = "gfggfggf"
brwWebBrowser.Document.Forms(0).submit() = True
DoEvents
While brwWebBrowser.Busy = True
DoEvents
Wend
End Sub
Re: [RESOLVED] Auto Login Issue
Hi All, Here is full code used to Auto login, Modified by Max187Boucher. I post it here so anyone can get benefit in return. Please folk if any one found this code useful Rate Max187Boucher. Thank you
Code:
Option Explicit
Private Declare Sub Sleep Lib "kernel32.dll" (ByVal dwMilliseconds As Long)
Private IE As Object
Private Sub Form_Load()
On Error GoTo IE_Error
IE.Visible = True 'Make sure is Visible AND also checks if IE is Set... if not set then goto IE_Error
'Here below you would put your code to control document example below
Debug.Print IE.Document.Body.InnerHTML
'More code here if needed
Exit Sub
IE_Error: 'Error 462(Window Closed) - Error 91(Object Not Set)
If Not Err.Number = 462 And Not Err.Number = 91 Then Exit Sub 'Exit if not error 462 or 91
'If is Error 462 or 91 then Create new Window
Set IE = CreateObject("InternetExplorer.Application")
IE.Visible = True
IE.Silent = True
IE.Navigate "https://put here your website"
Sleep 2000 'If the code below creates an error then change "Sleep 3000"
IE.Document.Forms.Form1.txtUsername.Value = "UserNameHere"
IE.Document.Forms.Form1.txtPassword.Value = "PassWordHere"
IE.Document.Forms.Form1.btnLogin.Click
Sleep 2000 'You do not want to rush login in because you will try to use document while still loging in...same as above
End Sub