2017-10-06 113 views
0

我正在尋求一些幫助,以瞭解如何使用Excel VBA在我們的辦公室的全球生產力中心中單擊「播放活動按鈕」。我正在用午餐創建一個出勤記錄工具,並打破追蹤器。一旦員工單擊使用我創建的工具登錄,GPH站點將啓動並將其登錄,與註銷同樣的事情。但是,我很難用我創建的工具來控制GPH網站的休息和午餐按鈕。我找不到要集成到我的vba代碼的正確元素。我希望有人能幫助我。請參閱下面的特定按鈕和圖像的HTML代碼。單擊網頁中的播放活動按鈕的VBA代碼

<tr class="top-five"> 
 
    <td title="Play Activity" class="glyphicon glyphicon-play-circle play-activity" data-toggle="tooltip" data-team-id="e9575e8b-4682-734c-b28d-b1ee5532a8ce" data-activity-id="e0728017-a4fa-ef4b-91a6-262e5418a134" data-team-name="Technology Team"> </td> 
 
<td> 
 
    <span title="Break Activities" class="act-ellipsis" data-toggle="tooltip"> 
 
<span class="ellip ellip-line"> Break Activities </span> 
 

 
</span> 
 
Break 
 
</td> 
 

 
<td title="Favorite" class="glyphicon glyphicon-star" data-toggle="tooltip" data-activity-id="e0728017-a4fa-ef4b-91a6-262e5418a134"></td> 
 

 
</tr>

Image

回答

0

你的截屏太小,看不到任何細節,但基本上,它的工作原理是這樣的。

Dim HTMLDoc As HTMLDocument 
Dim oBrowser As InternetExplorer 
Sub Login_2_Website() 

Dim oHTML_Element As IHTMLElement 
Dim sURL As String 

On Error GoTo Err_Clear 
sURL = "https://www.google.com/accounts/Login" 
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.Email.Value = "[email protected]" 
HTMLDoc.all.passwd.Value = "*****" 

For Each oHTML_Element In HTMLDoc.getElementsByTagName("input") 
If oHTML_Element.Type = "submit" Then oHTML_Element.Click: Exit For 
Next 

' oBrowser.Refresh ' Refresh If Needed 
Err_Clear: 
If Err <> 0 Then 
Debug.Assert Err = 0 
Err.Clear 
Resume Next 
End If 
End Sub 

確保您設置爲引用...

Microsoft HTML Object Library 
Microsoft Internet Controls