2016-06-08 39 views
1
Sub login() 
    Dim IE As Object 
    Dim HTMLDoc As Object, HTMLDoc2 As Object 
    Dim objCollection As Object 

    Const navOpenInNewTab = &H800 
    Set IE = CreateObject("InternetExplorer.Application") 
    IE.Visible = True 
    IE.Navigate "https:///CWRWeb/displayMemberLogin.do" 

    Do While IE.Busy Or IE.ReadyState <> 4: Loop 

    Set HTMLDoc = IE.Document 

    With HTMLDoc 
    HTMLDoc.getElementByID("userID").Value = "yyyy" 'Entering credential 
    HTMLDoc.getElementByID("passwd").Value = "xxxxx" 
    End With 


    Set objCollection = IE.Document.getElementByID("login-s") 
    objCollection.Click 

End Sub 

我無法自動登錄點擊。登錄按鈕沒有用於輸入的ID。我不知道用什麼來獲取句柄.getElementBy ....無法訪問登錄按鈕..VBA代碼

回答

1

的形式有一個名字 - 你可以在你的用戶名和密碼填寫

HTMLDoc.Forms("loginFormBean").submit 
+0

正想後直接提交也可以建議這樣做,但可能會在按鈕的單擊事件中附加JavaScript功能。 – Jules

+0

跑了我,當我測試 – dbmitch

+0

是什麼形式表現在這裏? – Shank