我已經成功地使用網站登錄過去,但由於某種原因,我試圖自動化的最後兩個網站沒有一切工作。也許是因爲他們是jhtml和aspx網站,我不知道。下面是aspx的例子。希望對此有效的將與另一方合作。自動登錄網站使用VBA - 獲取「自動化錯誤」「未指定的錯誤」2147467259(80004005)
Sub ws8c()
Dim appIEc As SHDocVw.InternetExplorerMedium ' InternetExplorer
Set appIEc = New SHDocVw.InternetExplorer
appIEc.navigate "http://www.bentekenergy.com/Login.aspx"
While appIEc.Busy
DoEvents
Wend
' I get the error here! if I comment this out I get the error here too
appIEc.document.getElementById("ctl00_MasterMainContent_LoginCtrl_Username").Value = "MyUserName"
'if I comment the above line out I get the error here too
appIEc.document.getElementById("ctl00_MasterMainContent_LoginCtrl_Password").Value = "MyPW"
' This part doesn't work either...
Set ElementCol = appIEc.document.getElementsByTagName("a")
For Each btna In ElementCol
If btna.ID = "ctl00_MasterMainContent_LoginCtrl_btnSignIn" Then
btna.Click
Exit For
End If
Next btna
While appIEc.Busy
DoEvents
Wend
appIEc.navigate "http://www.bentekenergy.com/Benport/HubFlowMaps.aspx?sg=6", CLng(2048)
Set appIEc = Nothing
End Sub
我試圖使用其它技術像getElemengByTagName(「輸入」),然後通過循環並尋找該ID已如上所示。我不得不承認,我有點像其他人的帖子一樣,所以我可能會錯過一些重要的東西。什麼是瘋狂的,我有非常相似的代碼在其他地方工作....