0

我想出了如何使用 vba 自动登录,但我想用嵌入式网络浏览器做同样的事情。我尝试了网上找到的各种方法,但都没有成功。

谁能指出我正确的方向?

这是我目前所拥有的。我想让它在“sheet1.webbrowser1”上工作

Dim HTMLDoc As Object
Dim oBrowser As InternetExplorer
Sub Website_Login_Test()

Dim oHTML_Element As Object
Dim sURL As String

On Error GoTo Err_Clear
sURL = "http://example.com/login.action?os_destination=%2Fhomepage.action"

Set oBrowser = New InternetExplorer
oBrowser.Silent = True
oBrowser.timeout = 60
oBrowser.Navigate sURL
oBrowser.Visible = True

Do
' Wait till the Browser is loaded
Loop Until oBrowser.ReadyState = READYSTATE_COMPLETE

Set HTMLDoc = oBrowser.Document

HTMLDoc.all.os_username.Value = "this"
HTMLDoc.all.os_password.Value = "this"

HTMLDoc.all.os_cookie.Click
HTMLDoc.all.login.Click

' oBrowser.Refresh ' Refresh If Needed
Err_Clear:
If Err <> 0 Then
Err.Clear
Resume Next
End If
End Sub
4

1 回答 1

1
Dim oBrowser As Object
Set oBrowser = Sheet1.WebBrowser1
oBrowser.Navigate "http://www.google.com"
于 2013-10-17T23:16:22.113 回答