我想出了如何使用vba自动登录,但我想对嵌入式webbrowser做同样的事情。我尝试过在线发现的各种方法,但没有成功。
有人能指出我正确的方向吗?
这是我目前的情况。我想让它在“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
答案 0 :(得分:1)
Dim oBrowser As Object
Set oBrowser = Sheet1.WebBrowser1
oBrowser.Navigate "http://www.google.com"