Public Declare Function ShowWindow& Lib "user32" _
(ByVal hwnd As Long, ByVal nCmdShow As Integer)
Private Sub LoginWEB()
Dim ie As Object
On Error GoTo 1
Set ie = CreateObject("InternetExplorer.Application")
With ie
.navigate "http://www.baidu.com/login.php"
Do While .ReadyState <> 4: Loop
With .Document.Forms(3)
.Loginname.Value = "用户名"
.Loginpass.Value = "密码"
.buttlogin.Click
End With
Do While CBool(InStrB(1, .Document.url, "http:// www.baidu.com /login.php"))
DoEvents: Loop
Do While CBool(InStrB(1, .Document.url, "http:// www.baidu.com /exit.php"))
DoEvents: Loop
Call ShowWindow(.hwnd, 3)
.Visible = True
End With
Set ie = Nothing
Exit Sub
1:
MsgBox "非预期错误, sorry."
ie.Quit
Set ie = Nothing
End Sub |