2017-04-23 2 views
0

안녕 모두를 얻을.VBA 열기 웹 페이지, 로그인 및 내 Access에서 함수, 웹 페이지를 열어 사용자 이름과 암호를 채우고 다음 로그인 & VBA 작은 응용 프로그램을 열린 페이지

웹 페이지에서 텍스트 필드와 다른 내용을 읽을 수 있습니까? 예를 들어 로그인 한 후에 웹 페이지를 열었을 때와 동일한 링크가있는 새 웹 페이지가 아닌 경우 어떻게해야합니까?

이것은 내 코드입니다.

은 감사 당신은 그것의 이름으로 텍스트 필드의 값에 액세스 그런 다음, 클릭 버튼에 응답 페이지에 대한 대기를 추가

Private Sub myButton_Click() 
Dim IE As Object 
Dim IEDoc As HTMLDocument 

Set IE = CreateObject("InternetExplorer.application") 
Set IEDoc = IE.Document 
IE.Navigate "http://mylogin.com" 
Do While IE.Busy: DoEvents: Loop 
While IE.ReadyState <> READYSTATE_COMPLETE 
DoEvents 
Wend 

With IEDoc 
     .getElementsByName("userid")(0).Value = "user" 
     .getElementsByName("password")(0).Value = "password" 
     .getElementById("btn_login").Click 
End With 

'At this point, I would read a text field from the new opened page, after login, in the same browser (not from a new webpage with the same link) 

답변

1

모든

Private Sub myButton_Click() 
Dim IE As Object 
Dim IEDoc As HTMLDocument 

Set IE = CreateObject("InternetExplorer.application") 
Set IEDoc = IE.Document 
IE.Navigate "http://mylogin.com" 
Do While IE.Busy: DoEvents: Loop 
While IE.ReadyState <> READYSTATE_COMPLETE 
DoEvents 
Wend 

With IEDoc 
     .getElementsByName("userid")(0).Value = "user" 
     .getElementsByName("password")(0).Value = "password" 
     .getElementById("btn_login").Click 
End With 

'At this point, I would read a text field from the new opened page, after login, in the same browser (not from a new webpage with the same link) 
Do While IE.Busy: DoEvents: Loop 
While IE.ReadyState <> READYSTATE_COMPLETE 
    DoEvents 
Wend 
With IEDoc 
     msgbox .getElementsByName("thetextfield").Value 
End With 
관련 문제