Excel 高级编程:VBA自动登陆论坛的代码
Sub EP()
Dim IE As Object, timeie As Date
Dim sUser As String, sPwd As String
'sUser = "Excel教程" 'InputBox("请键入用户名:")
' sPwd = "123456" 'InputBox("请键入登录密码:")
On Error Resume Next
Set IE = CreateObject("InternetExplorer.application")
IE.Visible = True
IE.Navigate "" '只把这一句话改了就OK了
timeie = DateAdd("s", 60, Now()) '最久等待60秒
Do While IE.Busy And Not IE.ReadyState = READYSTATE_COMPLETE
DoEvents
If timeie < Now() Then
MsgBox "无法连接网站,请重新执行"
IE.Quit
Exit Sub
End If
Loop
IE.Document.all.UserName.Value = "ID"
IE.Document.all.Password.Value = "密码"
IE.Document.all.submit.Click ' 还有这一句话改了就OK了
End Sub
Dim IE As Object, timeie As Date
Dim sUser As String, sPwd As String
'sUser = "Excel教程" 'InputBox("请键入用户名:")
' sPwd = "123456" 'InputBox("请键入登录密码:")
On Error Resume Next
Set IE = CreateObject("InternetExplorer.application")
IE.Visible = True
IE.Navigate "" '只把这一句话改了就OK了
timeie = DateAdd("s", 60, Now()) '最久等待60秒
Do While IE.Busy And Not IE.ReadyState = READYSTATE_COMPLETE
DoEvents
If timeie < Now() Then
MsgBox "无法连接网站,请重新执行"
IE.Quit
Exit Sub
End If
Loop
IE.Document.all.UserName.Value = "ID"
IE.Document.all.Password.Value = "密码"
IE.Document.all.submit.Click ' 还有这一句话改了就OK了
End Sub