我想直接從 Excel VBA 打開一個網頁,我需要點擊沒有 ID 的“活動目錄”按鈕。此按鈕使用 Windows 憑據自動登錄,因此我只需單擊此處,稍后登錄后我就可以開始填充一些欄位。
這個通用代碼給了我一條錯誤訊息
" 呼叫的物件已與其客戶端斷開連接"
我認為它與網頁安全登錄有關。
Sub test()
Const sSiteName = "https://www.padb.ford.com/PadbStrutsWeb/treeHomePre.do"
Dim oIE As Object
Dim oHDoc As HTMLDocument
Set oIE = CreateObject("InternetExplorer.Application")
With oIE
.Visible = True
.navigate sSiteName
End With
While oIE.readyState <> 4
DoEvents
Wend
Set oHDoc = oIE.document
With oHDoc
'Here I want to click on that button so I can latter populate some of the fields, once page is loaded'
End With
End Sub
uj5u.com熱心網友回復:
IE 已停產,不應再使用。
我無法告訴您在頁面上單擊按鈕的準確程度,因為這需要 HTML 代碼。但是與客戶端的斷開連接可能是由于 IE 的初始化方式。通過 GUID D5E8041D-920F-45e9-B8FB-B1DEB82C6E5E 嘗試
Sub test()
Const sSiteName = "https://www.padb.ford.com/PadbStrutsWeb/treeHomePre.do"
Dim oIE As Object
Dim oHDoc As HTMLDocument
Set oIE = GetObject("new:{D5E8041D-920F-45e9-B8FB-B1DEB82C6E5E}")
With oIE
.Visible = True
.navigate sSiteName
End With
While oIE.readyState <> 4
DoEvents
Wend
Set oHDoc = oIE.document
With oHDoc
'Here I want to click on that button so I can latter populate some of the fields, once page is loaded'
End With
End Sub
轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/490278.html
