我正在开发一种工具来捕捉团队成员的使用情况。我正在尝试在 excel 中获取用户的休息时间。请建议我一个 vba 代码,当用户不在 LYNC 上时,它将在 excel 中启动一个计时器,并在他/她在线时停止计时器。这就是我如何让用户离开的时间,剩下的就是利用。:)
问问题
2284 次
1 回答
1
我已经完成了......下面是我使用的代码,它工作正常。我对其进行了一些更改以达到我的目的。
'This Macro is working fine
Public Sub macro10()
LyncContactsStatus
End Sub
Function LyncContactsStatus() As Variant
Dim appLync As CommunicatorAPI.Messenger
Dim LyncDirectory As CommunicatorAPI.IMessengerContacts
Dim LyncContact As CommunicatorAPI.IMessengerContact
Dim arrContacts() As Variant
Dim lngLoopCount As Long
Set appLync = CreateObject("Communicator.UIAutomation")
appLync.AutoSignin
Set LyncDirectory = appLync.MyContacts
ReDim arrContacts(LyncDirectory.Count - 1, 1)
For lngLoopCount = 0 To LyncDirectory.Count - 1
Set LyncContact = LyncDirectory.Item(lngLoopCount)
arrContacts(lngLoopCount, 0) = LyncContact.FriendlyName
arrContacts(lngLoopCount, 1) = LyncStatus(LyncContact.Status)
ActiveCell.Value = LyncContact.FriendlyName
ActiveCell.Offset(0, 1).Value = LyncContact.Status
If LyncContact.Status = MISTATUS_AWAY Then
If ActiveCell.Offset(0, 3).Value = "" Then
ActiveCell.Offset(0, 3).Value = Now
End If
End If
If LyncContact.Status = MISTATUS_ONLINE Then
If ActiveCell.Offset(0, 3).Value <> "" Then
ActiveCell.Offset(0, 4).Value = Now
Sheet1.Range(ActiveCell, ActiveCell.Offset(0, 4)).Select
Selection.Copy
Dim i
i = 1
Do
i = i + 1
If Sheet2.Cells(i, 1).Value = "" Then
Sheet2.Activate
Cells(i, 1).Select
'Sheet2.Activate
Sheet2.Paste
i = i + 1
Sheet1.Activate
End If
Loop Until Sheet2.Cells(i, 1).Value = ""
ActiveCell.Offset(0, 3) = ""
ActiveCell.Offset(0, 4) = ""
End If
End If
ActiveCell.Offset(1, 0).Activate
Next lngLoopCount
LyncContactsStatus = arrContacts
Set appLync = Nothing
Cells(1, 1).Activate
Application.OnTime Now + TimeValue("00:00:30"), "Macro10"
End Function
Function LyncStatus(IntStatus As Integer) As String
Select Case IntStatus
Case 1 'MISTATUS_OFFLINE
LyncStatus = "Offline"
Case 2 'MISTATUS_ONLINE
LyncStatus = "Online"
Case 6 'MISTATUS_INVISIBLE
LyncStatus = "Invisible"
Case 10 'MISTATUS_BUSY
LyncStatus = "Busy"
Case 14 'MISTATUS_BE_RIGHT_BACK
LyncStatus = "Be Right Back"
Case 18 'MISTATUS_IDLE
LyncStatus = "Idle"
Case 34 'MISTATUS_AWAY
LyncStatus = "Away"
Case 50 'MISTATUS_ON_THE_PHONE
LyncStatus = "On the Phone"
Case 66 'MISTATUS_OUT_TO_LUNCH
LyncStatus = "Out to Lunch"
Case 82 'MISTATUS_IN_A_MEETING
LyncStatus = "In a meeting"
Case 98 'MISTATUS_OUT_OF_OFFICE
LyncStatus = "Out of office"
Case 114 'MISTATUS_OUT_OF_OFFICE
LyncStatus = "Do not disturb"
Case 130 'MISTATUS_IN_A_CONFERENCE
LyncStatus = "In a conference"
Case Else
LyncStatus = "Unknown"
End Select
End Function
此代码将在表 2 中记录您的联系人的休息时间。
如需任何帮助,请发送邮件至“Rohan.shona@gmail.com”
于 2016-12-29T09:25:37.853 回答